diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/mem.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c index 5a661e5f45..3b5b2bbc68 100644 --- a/src/lib/libcrypto/mem.c +++ b/src/lib/libcrypto/mem.c | |||
| @@ -80,20 +80,23 @@ static void (*free_func)(void *) = free; | |||
| 80 | /* may be changed as long as `allow_customize_debug' is set */ | 80 | /* may be changed as long as `allow_customize_debug' is set */ |
| 81 | /* XXX use correct function pointer types */ | 81 | /* XXX use correct function pointer types */ |
| 82 | #ifdef CRYPTO_MDEBUG | 82 | #ifdef CRYPTO_MDEBUG |
| 83 | /* use default functions from mem_dbg.c */ | 83 | /* use default functions from mem_dbg.c */ |
| 84 | static void (*malloc_debug_func)()= (void (*)())CRYPTO_dbg_malloc; | 84 | static void (*malloc_debug_func)(void *,int,const char *,int,int) |
| 85 | static void (*realloc_debug_func)()= (void (*)())CRYPTO_dbg_realloc; | 85 | = CRYPTO_dbg_malloc; |
| 86 | static void (*free_debug_func)()= (void (*)())CRYPTO_dbg_free; | 86 | static void (*realloc_debug_func)(void *,void *,int,const char *,int,int) |
| 87 | static void (*set_debug_options_func)()= (void (*)())CRYPTO_dbg_set_options; | 87 | = CRYPTO_dbg_realloc; |
| 88 | static long (*get_debug_options_func)()= (long (*)())CRYPTO_dbg_get_options; | 88 | static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free; |
| 89 | static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options; | ||
| 90 | static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options; | ||
| 89 | #else | 91 | #else |
| 90 | /* applications can use CRYPTO_malloc_debug_init() to select above case | 92 | /* applications can use CRYPTO_malloc_debug_init() to select above case |
| 91 | * at run-time */ | 93 | * at run-time */ |
| 92 | static void (*malloc_debug_func)()= NULL; | 94 | static void (*malloc_debug_func)(void *,int,const char *,int,int) = NULL; |
| 93 | static void (*realloc_debug_func)()= NULL; | 95 | static void (*realloc_debug_func)(void *,void *,int,const char *,int,int) |
| 94 | static void (*free_debug_func)()= NULL; | 96 | = NULL; |
| 95 | static void (*set_debug_options_func)()= NULL; | 97 | static void (*free_debug_func)(void *,int) = NULL; |
| 96 | static long (*get_debug_options_func)()= NULL; | 98 | static void (*set_debug_options_func)(long) = NULL; |
| 99 | static long (*get_debug_options_func)(void) = NULL; | ||
| 97 | #endif | 100 | #endif |
| 98 | 101 | ||
| 99 | 102 | ||
| @@ -123,7 +126,11 @@ int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *)) | |||
| 123 | return 1; | 126 | return 1; |
| 124 | } | 127 | } |
| 125 | 128 | ||
| 126 | int CRYPTO_set_mem_debug_functions(void (*m)(), void (*r)(), void (*f)(),void (*so)(),long (*go)()) | 129 | int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), |
| 130 | void (*r)(void *,void *,int,const char *,int,int), | ||
| 131 | void (*f)(void *,int), | ||
| 132 | void (*so)(long), | ||
| 133 | long (*go)(void)) | ||
| 127 | { | 134 | { |
| 128 | if (!allow_customize_debug) | 135 | if (!allow_customize_debug) |
| 129 | return 0; | 136 | return 0; |
| @@ -149,7 +156,11 @@ void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)) | |||
| 149 | if (f != NULL) *f=free_locked_func; | 156 | if (f != NULL) *f=free_locked_func; |
| 150 | } | 157 | } |
| 151 | 158 | ||
| 152 | void CRYPTO_get_mem_debug_functions(void (**m)(), void (**r)(), void (**f)(),void (**so)(),long (**go)()) | 159 | void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), |
| 160 | void (**r)(void *,void *,int,const char *,int,int), | ||
| 161 | void (**f)(void *,int), | ||
| 162 | void (**so)(long), | ||
| 163 | long (**go)(void)) | ||
| 153 | { | 164 | { |
| 154 | if (m != NULL) *m=malloc_debug_func; | 165 | if (m != NULL) *m=malloc_debug_func; |
| 155 | if (r != NULL) *r=realloc_debug_func; | 166 | if (r != NULL) *r=realloc_debug_func; |
| @@ -161,7 +172,7 @@ void CRYPTO_get_mem_debug_functions(void (**m)(), void (**r)(), void (**f)(),voi | |||
| 161 | 172 | ||
| 162 | void *CRYPTO_malloc_locked(int num, const char *file, int line) | 173 | void *CRYPTO_malloc_locked(int num, const char *file, int line) |
| 163 | { | 174 | { |
| 164 | char *ret = NULL; | 175 | void *ret = NULL; |
| 165 | 176 | ||
| 166 | allow_customize = 0; | 177 | allow_customize = 0; |
| 167 | if (malloc_debug_func != NULL) | 178 | if (malloc_debug_func != NULL) |
| @@ -193,7 +204,7 @@ void CRYPTO_free_locked(void *str) | |||
| 193 | 204 | ||
| 194 | void *CRYPTO_malloc(int num, const char *file, int line) | 205 | void *CRYPTO_malloc(int num, const char *file, int line) |
| 195 | { | 206 | { |
| 196 | char *ret = NULL; | 207 | void *ret = NULL; |
| 197 | 208 | ||
| 198 | allow_customize = 0; | 209 | allow_customize = 0; |
| 199 | if (malloc_debug_func != NULL) | 210 | if (malloc_debug_func != NULL) |
| @@ -213,7 +224,7 @@ void *CRYPTO_malloc(int num, const char *file, int line) | |||
| 213 | 224 | ||
| 214 | void *CRYPTO_realloc(void *str, int num, const char *file, int line) | 225 | void *CRYPTO_realloc(void *str, int num, const char *file, int line) |
| 215 | { | 226 | { |
| 216 | char *ret = NULL; | 227 | void *ret = NULL; |
| 217 | 228 | ||
| 218 | if (realloc_debug_func != NULL) | 229 | if (realloc_debug_func != NULL) |
| 219 | realloc_debug_func(str, NULL, num, file, line, 0); | 230 | realloc_debug_func(str, NULL, num, file, line, 0); |
| @@ -241,8 +252,8 @@ void CRYPTO_free(void *str) | |||
| 241 | 252 | ||
| 242 | void *CRYPTO_remalloc(void *a, int num, const char *file, int line) | 253 | void *CRYPTO_remalloc(void *a, int num, const char *file, int line) |
| 243 | { | 254 | { |
| 244 | if (a != NULL) Free(a); | 255 | if (a != NULL) OPENSSL_free(a); |
| 245 | a=(char *)Malloc(num); | 256 | a=(char *)OPENSSL_malloc(num); |
| 246 | return(a); | 257 | return(a); |
| 247 | } | 258 | } |
| 248 | 259 | ||
