diff options
author | djm <> | 2009-01-09 12:14:09 +0000 |
---|---|---|
committer | djm <> | 2009-01-09 12:14:09 +0000 |
commit | 76dd4d55fdccad54d20608e7caf577b9d67b216f (patch) | |
tree | 9b645adc5cf0aa0820e1501ee5c6f2c41c454e7c /src/lib/libcrypto/mem.c | |
parent | f1625f274acf5dcd5601f6cb5e29e233b2a441a3 (diff) | |
download | openbsd-76dd4d55fdccad54d20608e7caf577b9d67b216f.tar.gz openbsd-76dd4d55fdccad54d20608e7caf577b9d67b216f.tar.bz2 openbsd-76dd4d55fdccad54d20608e7caf577b9d67b216f.zip |
import openssl-0.9.8j
Diffstat (limited to 'src/lib/libcrypto/mem.c')
-rw-r--r-- | src/lib/libcrypto/mem.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/lib/libcrypto/mem.c b/src/lib/libcrypto/mem.c index 6635167228..00ebaf0b9b 100644 --- a/src/lib/libcrypto/mem.c +++ b/src/lib/libcrypto/mem.c | |||
@@ -101,7 +101,7 @@ static void (*free_locked_func)(void *) = free; | |||
101 | 101 | ||
102 | /* may be changed as long as 'allow_customize_debug' is set */ | 102 | /* may be changed as long as 'allow_customize_debug' is set */ |
103 | /* XXX use correct function pointer types */ | 103 | /* XXX use correct function pointer types */ |
104 | #ifdef CRYPTO_MDEBUG | 104 | #if defined(CRYPTO_MDEBUG) && !defined(OPENSSL_FIPS) |
105 | /* use default functions from mem_dbg.c */ | 105 | /* use default functions from mem_dbg.c */ |
106 | static void (*malloc_debug_func)(void *,int,const char *,int,int) | 106 | static void (*malloc_debug_func)(void *,int,const char *,int,int) |
107 | = CRYPTO_dbg_malloc; | 107 | = CRYPTO_dbg_malloc; |
@@ -110,6 +110,14 @@ static void (*realloc_debug_func)(void *,void *,int,const char *,int,int) | |||
110 | static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free; | 110 | static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free; |
111 | static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options; | 111 | static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options; |
112 | static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options; | 112 | static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options; |
113 | |||
114 | static int (*push_info_func)(const char *info, const char *file, int line) | ||
115 | = CRYPTO_dbg_push_info; | ||
116 | static int (*pop_info_func)(void) | ||
117 | = CRYPTO_dbg_pop_info; | ||
118 | static int (*remove_all_info_func)(void) | ||
119 | = CRYPTO_dbg_remove_all_info; | ||
120 | |||
113 | #else | 121 | #else |
114 | /* applications can use CRYPTO_malloc_debug_init() to select above case | 122 | /* applications can use CRYPTO_malloc_debug_init() to select above case |
115 | * at run-time */ | 123 | * at run-time */ |
@@ -119,6 +127,13 @@ static void (*realloc_debug_func)(void *,void *,int,const char *,int,int) | |||
119 | static void (*free_debug_func)(void *,int) = NULL; | 127 | static void (*free_debug_func)(void *,int) = NULL; |
120 | static void (*set_debug_options_func)(long) = NULL; | 128 | static void (*set_debug_options_func)(long) = NULL; |
121 | static long (*get_debug_options_func)(void) = NULL; | 129 | static long (*get_debug_options_func)(void) = NULL; |
130 | |||
131 | |||
132 | static int (*push_info_func)(const char *info, const char *file, int line) | ||
133 | = NULL; | ||
134 | static int (*pop_info_func)(void) = NULL; | ||
135 | static int (*remove_all_info_func)(void) = NULL; | ||
136 | |||
122 | #endif | 137 | #endif |
123 | 138 | ||
124 | 139 | ||
@@ -194,6 +209,15 @@ int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), | |||
194 | return 1; | 209 | return 1; |
195 | } | 210 | } |
196 | 211 | ||
212 | void CRYPTO_set_mem_info_functions( | ||
213 | int (*push_info_fn)(const char *info, const char *file, int line), | ||
214 | int (*pop_info_fn)(void), | ||
215 | int (*remove_all_info_fn)(void)) | ||
216 | { | ||
217 | push_info_func = push_info_fn; | ||
218 | pop_info_func = pop_info_fn; | ||
219 | remove_all_info_func = remove_all_info_fn; | ||
220 | } | ||
197 | 221 | ||
198 | void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), | 222 | void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t), |
199 | void (**f)(void *)) | 223 | void (**f)(void *)) |
@@ -399,3 +423,24 @@ long CRYPTO_get_mem_debug_options(void) | |||
399 | return get_debug_options_func(); | 423 | return get_debug_options_func(); |
400 | return 0; | 424 | return 0; |
401 | } | 425 | } |
426 | |||
427 | int CRYPTO_push_info_(const char *info, const char *file, int line) | ||
428 | { | ||
429 | if (push_info_func) | ||
430 | return push_info_func(info, file, line); | ||
431 | return 1; | ||
432 | } | ||
433 | |||
434 | int CRYPTO_pop_info(void) | ||
435 | { | ||
436 | if (pop_info_func) | ||
437 | return pop_info_func(); | ||
438 | return 1; | ||
439 | } | ||
440 | |||
441 | int CRYPTO_remove_all_info(void) | ||
442 | { | ||
443 | if (remove_all_info_func) | ||
444 | return remove_all_info_func(); | ||
445 | return 1; | ||
446 | } | ||