Get rid of the function pointer casting in the debugging memory code due

to LHASH usage. NB: The callback type used as been suctioned off into
crypto.h as CRYPTO_MEM_LEAK_CB to improve clarity.
This commit is contained in:
Geoff Thorpe 2001-01-09 00:13:25 +00:00
parent 18602745de
commit 98d517c5da
2 changed files with 13 additions and 6 deletions

View File

@ -374,7 +374,8 @@ void CRYPTO_mem_leaks_fp(FILE *);
#endif #endif
void CRYPTO_mem_leaks(struct bio_st *bio); void CRYPTO_mem_leaks(struct bio_st *bio);
/* unsigned long order, char *file, int line, int num_bytes, char *addr */ /* 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); void ERR_load_CRYPTO_strings(void);

View File

@ -641,6 +641,8 @@ static void print_leak(MEM *m, MEM_LEAK *l)
#endif #endif
} }
static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, MEM *, MEM_LEAK *)
void CRYPTO_mem_leaks(BIO *b) void CRYPTO_mem_leaks(BIO *b)
{ {
MEM_LEAK ml; MEM_LEAK ml;
@ -653,7 +655,7 @@ void CRYPTO_mem_leaks(BIO *b)
ml.chunks=0; ml.chunks=0;
MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */ MemCheck_off(); /* obtains CRYPTO_LOCK_MALLOC2 */
if (mh != NULL) 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); (char *)&ml);
if (ml.chunks != 0) if (ml.chunks != 0)
{ {
@ -732,16 +734,20 @@ void CRYPTO_mem_leaks_fp(FILE *fp)
/* FIXME: We really don't allow much to the callback. For example, it has /* 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 no chance of reaching the info stack for the item it processes. Should
it really be this way? -- Richard Levitte */ it really be this way? -- Richard Levitte */
static void cb_leak(MEM *m, /* NB: The prototypes have been typedef'd to CRYPTO_MEM_LEAK_CB inside crypto.h
void (**cb)(unsigned long, const char *, int, int, void *)) * 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); (**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; if (mh == NULL) return;
CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2); 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); CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
} }