summaryrefslogtreecommitdiffstats
path: root/crypto/objects/o_names.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2000-12-08 21:02:01 +0100
committerGeoff Thorpe <geoff@openssl.org>2000-12-08 21:02:01 +0100
commitd0fa136ce22bb57638a1bf18e656602f53081ff3 (patch)
treeb28c81ccdfe238a0e655b3ab906095a7589c133b /crypto/objects/o_names.c
parentbn_part_sub_word prototype. (diff)
downloadopenssl-d0fa136ce22bb57638a1bf18e656602f53081ff3.tar.xz
openssl-d0fa136ce22bb57638a1bf18e656602f53081ff3.zip
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/o_names.c')
-rw-r--r--crypto/objects/o_names.c23
1 files changed, 15 insertions, 8 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))
{