summaryrefslogtreecommitdiffstats
path: root/crypto/mem_dbg.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2000-12-08 20:02:01 +0000
committerGeoff Thorpe <geoff@openssl.org>2000-12-08 20:02:01 +0000
commitd0fa136ce22bb57638a1bf18e656602f53081ff3 (patch)
treeb28c81ccdfe238a0e655b3ab906095a7589c133b /crypto/mem_dbg.c
parent15156cce0eed843d74ca06392144cad29c306ff7 (diff)
Next step in tidying up the LHASH code.
DECLARE/IMPLEMENT macros now exist to create type (and prototype) safe wrapper functions that avoid the use of function pointer casting yet retain type-safety for type-specific callbacks. However, most of the usage within OpenSSL itself doesn't really require the extra function because the hash and compare callbacks are internal functions declared only for use by the hash table. So this change catches all those cases and reimplements the functions using the base-level LHASH prototypes and does per-variable casting inside those functions to convert to the appropriate item type. The exception so far is in ssl_lib.c where the hash and compare callbacks are not static - they're exposed in ssl.h so their prototypes should not be changed. In this last case, the IMPLEMENT_LHASH_*** macros have been left intact.
Diffstat (limited to 'crypto/mem_dbg.c')
-rw-r--r--crypto/mem_dbg.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 56ce7dddea..8e48e25fbd 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -219,42 +219,40 @@ long CRYPTO_dbg_get_options(void)
return options;
}
-static int mem_cmp(MEM *a, MEM *b)
+/* static int mem_cmp(MEM *a, MEM *b) */
+static int mem_cmp(void *a_void, void *b_void)
{
- return((char *)a->addr - (char *)b->addr);
+ return((char *)((MEM *)a_void)->addr - (char *)((MEM *)b_void)->addr);
}
-static unsigned long mem_hash(MEM *a)
+/* static unsigned long mem_hash(MEM *a) */
+static unsigned long mem_hash(void *a_void)
{
unsigned long ret;
- ret=(unsigned long)a->addr;
+ ret=(unsigned long)((MEM *)a_void)->addr;
ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
return(ret);
}
-static IMPLEMENT_LHASH_HASH_FN(mem_hash, MEM *)
-static IMPLEMENT_LHASH_COMP_FN(mem_cmp, MEM *)
-
-static int app_info_cmp(APP_INFO *a, APP_INFO *b)
+/* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
+static int app_info_cmp(void *a_void, void *b_void)
{
- return(a->thread != b->thread);
+ return(((APP_INFO *)a_void)->thread != ((APP_INFO *)b_void)->thread);
}
-static unsigned long app_info_hash(APP_INFO *a)
+/* static unsigned long app_info_hash(APP_INFO *a) */
+static unsigned long app_info_hash(void *a_void)
{
unsigned long ret;
- ret=(unsigned long)a->thread;
+ ret=(unsigned long)((APP_INFO *)a_void)->thread;
ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
return(ret);
}
-static IMPLEMENT_LHASH_HASH_FN(app_info_hash, APP_INFO *)
-static IMPLEMENT_LHASH_COMP_FN(app_info_cmp, APP_INFO *)
-
static APP_INFO *pop_info(void)
{
APP_INFO tmp;
@@ -308,8 +306,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
}
if (amih == NULL)
{
- if ((amih=lh_new(LHASH_HASH_FN(app_info_hash),
- LHASH_COMP_FN(app_info_cmp))) == NULL)
+ if ((amih=lh_new(app_info_hash, app_info_cmp)) == NULL)
{
OPENSSL_free(ami);
ret=0;
@@ -401,8 +398,7 @@ void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
}
if (mh == NULL)
{
- if ((mh=lh_new(LHASH_HASH_FN(mem_hash),
- LHASH_COMP_FN(mem_cmp))) == NULL)
+ if ((mh=lh_new(mem_hash, mem_cmp)) == NULL)
{
OPENSSL_free(addr);
OPENSSL_free(m);