diff options
author | Geoff Thorpe <geoff@openssl.org> | 2001-01-09 00:13:25 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2001-01-09 00:13:25 +0000 |
commit | 98d517c5dad7812f2df30f001356eb4cfa7fa6fc (patch) | |
tree | eb7027d5fd78a6892cf6152200cb79193be12620 /crypto | |
parent | 18602745de52e5869f3865245c3c72986831dae2 (diff) | |
download | openssl-98d517c5dad7812f2df30f001356eb4cfa7fa6fc.tar.gz |
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.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crypto.h | 3 | ||||
-rw-r--r-- | crypto/mem_dbg.c | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/crypto/crypto.h b/crypto/crypto.h index 08bb1fc83e..96a852a703 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -374,7 +374,8 @@ void CRYPTO_mem_leaks_fp(FILE *); #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); diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index a6c70e431a..fb1fdd7453 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -641,6 +641,8 @@ static void print_leak(MEM *m, MEM_LEAK *l) #endif } +static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, MEM *, MEM_LEAK *) + void CRYPTO_mem_leaks(BIO *b) { MEM_LEAK ml; @@ -653,7 +655,7 @@ void CRYPTO_mem_leaks(BIO *b) 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) { @@ -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 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); } |