aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/objects
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/objects
parent15156cce0eed843d74ca06392144cad29c306ff7 (diff)
downloadopenssl-d0fa136ce22bb57638a1bf18e656602f53081ff3.tar.gz
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/objects')
-rw-r--r--crypto/objects/o_names.c23
-rw-r--r--crypto/objects/obj_dat.c14
2 files changed, 23 insertions, 14 deletions
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c
index ccf3a18726..a5b1aacd66 100644
--- a/crypto/objects/o_names.c
+++ b/crypto/objects/o_names.c
@@ -24,18 +24,20 @@ IMPLEMENT_STACK_OF(NAME_FUNCS)
static STACK_OF(NAME_FUNCS) *name_funcs_stack;
-static unsigned long obj_name_hash(OBJ_NAME *a);
-static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b);
+/* The LHASH callbacks now use the raw "void *" prototypes and do per-variable
+ * casting in the functions. This prevents function pointer casting without the
+ * need for macro-generated wrapper functions. */
-static IMPLEMENT_LHASH_HASH_FN(obj_name_hash, OBJ_NAME *)
-static IMPLEMENT_LHASH_COMP_FN(obj_name_cmp, OBJ_NAME *)
+/* static unsigned long obj_name_hash(OBJ_NAME *a); */
+static unsigned long obj_name_hash(void *a_void);
+/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */
+static int obj_name_cmp(void *a_void,void *b_void);
int OBJ_NAME_init(void)
{
if (names_lh != NULL) return(1);
MemCheck_off();
- names_lh=lh_new(LHASH_HASH_FN(obj_name_hash),
- LHASH_COMP_FN(obj_name_cmp));
+ names_lh=lh_new(obj_name_hash, obj_name_cmp);
MemCheck_on();
return(names_lh != NULL);
}
@@ -85,9 +87,12 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
return(ret);
}
-static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
+/* static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b) */
+static int obj_name_cmp(void *a_void, void *b_void)
{
int ret;
+ OBJ_NAME *a = (OBJ_NAME *)a_void;
+ OBJ_NAME *b = (OBJ_NAME *)b_void;
ret=a->type-b->type;
if (ret == 0)
@@ -104,9 +109,11 @@ static int obj_name_cmp(OBJ_NAME *a, OBJ_NAME *b)
return(ret);
}
-static unsigned long obj_name_hash(OBJ_NAME *a)
+/* static unsigned long obj_name_hash(OBJ_NAME *a) */
+static unsigned long obj_name_hash(void *a_void)
{
unsigned long ret;
+ OBJ_NAME *a = (OBJ_NAME *)a_void;
if ((name_funcs_stack != NULL) && (sk_NAME_FUNCS_num(name_funcs_stack) > a->type))
{
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index 6eb9f48861..0057da29bd 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -108,12 +108,14 @@ static int ln_cmp(const void *a, const void *b)
return(strcmp((*ap)->ln,(*bp)->ln));
}
-static unsigned long add_hash(ADDED_OBJ *ca)
+/* static unsigned long add_hash(ADDED_OBJ *ca) */
+static unsigned long add_hash(void *ca_void)
{
ASN1_OBJECT *a;
int i;
unsigned long ret=0;
unsigned char *p;
+ ADDED_OBJ *ca = (ADDED_OBJ *)ca_void;
a=ca->obj;
switch (ca->type)
@@ -142,10 +144,13 @@ static unsigned long add_hash(ADDED_OBJ *ca)
return(ret);
}
-static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb)
+/* static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb) */
+static int add_cmp(void *ca_void, void *cb_void)
{
ASN1_OBJECT *a,*b;
int i;
+ ADDED_OBJ *ca = (ADDED_OBJ *)ca_void;
+ ADDED_OBJ *cb = (ADDED_OBJ *)cb_void;
i=ca->type-cb->type;
if (i) return(i);
@@ -174,13 +179,10 @@ static int add_cmp(ADDED_OBJ *ca, ADDED_OBJ *cb)
return(1); /* should not get here */
}
-static IMPLEMENT_LHASH_HASH_FN(add_hash, ADDED_OBJ *)
-static IMPLEMENT_LHASH_COMP_FN(add_cmp, ADDED_OBJ *)
-
static int init_added(void)
{
if (added != NULL) return(1);
- added=lh_new(LHASH_HASH_FN(add_hash),LHASH_COMP_FN(add_cmp));
+ added=lh_new(add_hash,add_cmp);
return(added != NULL);
}