#endif
void CRYPTO_mem_leaks(struct bio_st *bio);
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
-void CRYPTO_mem_leaks_cb(void (*cb)(unsigned long, const char *, int, int, void *));
+typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
+void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB cb);
void ERR_load_CRYPTO_strings(void);
#endif
}
+static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, MEM *, MEM_LEAK *)
+
void CRYPTO_mem_leaks(BIO *b)
{
MEM_LEAK ml;
ml.chunks=0;
MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
if (mh != NULL)
- lh_doall_arg(mh, (LHASH_DOALL_ARG_FN_TYPE)print_leak,
+ lh_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak),
(char *)&ml);
if (ml.chunks != 0)
{
/* FIXME: We really don't allow much to the callback. For example, it has
no chance of reaching the info stack for the item it processes. Should
it really be this way? -- Richard Levitte */
-static void cb_leak(MEM *m,
- void (**cb)(unsigned long, const char *, int, int, void *))
+/* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h
+ * If this code is restructured, remove the callback type if it is no longer
+ * needed. -- Geoff Thorpe */
+static void cb_leak(MEM *m, CRYPTO_MEM_LEAK_CB *cb)
{
(**cb)(m->order,m->file,m->line,m->num,m->addr);
}
-void CRYPTO_mem_leaks_cb(void (*cb)(unsigned long, const char *, int, int, void *))
+static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, MEM *, CRYPTO_MEM_LEAK_CB *)
+
+void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB cb)
{
if (mh == NULL) return;
CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
- lh_doall_arg(mh, (LHASH_DOALL_ARG_FN_TYPE)cb_leak,(void *)&cb);
+ lh_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), &cb);
CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
}