2 * include/ssl_applink.c -- common NTP code for openssl/applink.c
4 * Each program which uses OpenSSL should include this file in _one_
5 * of its source files and call ssl_applink() before any OpenSSL
9 #if defined(OPENSSL) && defined(SYS_WINNT)
11 # pragma warning(push)
12 # pragma warning(disable: 4152)
14 # include <openssl/applink.c>
20 #if defined(OPENSSL) && defined(_MSC_VER) && defined(_DEBUG)
21 #define WRAP_DBG_MALLOC
24 #ifdef WRAP_DBG_MALLOC
25 void *wrap_dbg_malloc(size_t s, const char *f, int l);
26 void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l);
27 void wrap_dbg_free(void *p);
31 #if defined(OPENSSL) && defined(SYS_WINNT)
32 void ssl_applink(void);
37 #ifdef WRAP_DBG_MALLOC
38 CRYPTO_set_mem_ex_functions(wrap_dbg_malloc, wrap_dbg_realloc, wrap_dbg_free);
43 #else /* !OPENSSL || !SYS_WINNT */
44 #define ssl_applink() do {} while (0)
48 #ifdef WRAP_DBG_MALLOC
50 * OpenSSL malloc overriding uses different parameters
51 * for DEBUG malloc/realloc/free (lacking block type).
52 * Simple wrappers convert.
54 void *wrap_dbg_malloc(size_t s, const char *f, int l)
58 ret = _malloc_dbg(s, _NORMAL_BLOCK, f, l);
62 void *wrap_dbg_realloc(void *p, size_t s, const char *f, int l)
66 ret = _realloc_dbg(p, s, _NORMAL_BLOCK, f, l);
70 void wrap_dbg_free(void *p)
72 _free_dbg(p, _NORMAL_BLOCK);
74 #endif /* WRAP_DBG_MALLOC */