1 /* $OpenBSD: malloc-wrapper.c,v 1.6 2017/05/02 03:59:44 deraadt Exp $ */
3 * Copyright (c) 2014 Bob Beck
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 CRYPTO_set_mem_functions(void *(*m
)(size_t), void *(*r
)(void *, size_t),
29 CRYPTO_set_mem_ex_functions(void *(*m
)(size_t, const char *, int),
30 void *(*r
)(void *, size_t, const char *, int), void (*f
)(void *))
36 CRYPTO_set_locked_mem_functions(void *(*m
)(size_t), void (*f
)(void *))
42 CRYPTO_set_locked_mem_ex_functions(void *(*m
)(size_t, const char *, int),
49 CRYPTO_set_mem_debug_functions(void (*m
)(void *, int, const char *, int, int),
50 void (*r
)(void *, void *, int, const char *, int, int),
51 void (*f
)(void *, int), void (*so
)(long), long (*go
)(void))
58 CRYPTO_get_mem_functions(void *(**m
)(size_t), void *(**r
)(void *, size_t),
70 CRYPTO_get_mem_ex_functions(void *(**m
)(size_t, const char *, int),
71 void *(**r
)(void *, size_t, const char *, int), void (**f
)(void *))
82 CRYPTO_get_locked_mem_functions(void *(**m
)(size_t), void (**f
)(void *))
91 CRYPTO_get_locked_mem_ex_functions(void *(**m
)(size_t, const char *, int),
101 CRYPTO_get_mem_debug_functions(void (**m
)(void *, int, const char *, int, int),
102 void (**r
)(void *, void *, int, const char *, int, int),
103 void (**f
)(void *, int), void (**so
)(long), long (**go
)(void))
119 CRYPTO_malloc_locked(int num
, const char *file
, int line
)
127 CRYPTO_free_locked(void *ptr
)
133 CRYPTO_malloc(int num
, const char *file
, int line
)
141 CRYPTO_strdup(const char *str
, const char *file
, int line
)
147 CRYPTO_realloc(void *ptr
, int num
, const char *file
, int line
)
152 return realloc(ptr
, num
);
156 CRYPTO_realloc_clean(void *ptr
, int old_len
, int num
, const char *file
,
164 return NULL
; /* original does not support shrinking */
166 if (ret
&& ptr
&& old_len
> 0) {
167 memcpy(ret
, ptr
, old_len
);
168 freezero(ptr
, old_len
);
174 CRYPTO_free(void *ptr
)
180 CRYPTO_remalloc(void *a
, int num
, const char *file
, int line
)
187 CRYPTO_set_mem_debug_options(long bits
)
193 CRYPTO_get_mem_debug_options(void)