Move all the existing function pointer casts associated with LHASH's two
[openssl.git] / crypto / objects / o_names.c
index 288f0081496eae0518c331b004ffaeffe7917023..03d65397b84ec63876eb32c59c055bfb87f2ea1f 100644 (file)
@@ -24,14 +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 unsigned long obj_name_hash(OBJ_NAME *a); */
+static unsigned long obj_name_hash(const void *a_void);
+/* static int obj_name_cmp(OBJ_NAME *a,OBJ_NAME *b); */
+static int obj_name_cmp(const void *a_void,const void *b_void);
 
 int OBJ_NAME_init(void)
        {
        if (names_lh != NULL) return(1);
        MemCheck_off();
-       names_lh=lh_new(obj_name_hash,obj_name_cmp);
+       names_lh=lh_new(obj_name_hash, obj_name_cmp);
        MemCheck_on();
        return(names_lh != NULL);
        }
@@ -81,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(const void *a_void, const 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)
@@ -100,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(const 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))
                {
@@ -237,6 +248,8 @@ static void do_all_fn(const OBJ_NAME *name,struct doall *d)
                d->fn(name,d->arg);
        }
 
+static IMPLEMENT_LHASH_DOALL_ARG_FN(do_all_fn, const OBJ_NAME *, struct doall *)
+
 void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
        {
        struct doall d;
@@ -245,7 +258,7 @@ void OBJ_NAME_do_all(int type,void (*fn)(const OBJ_NAME *,void *arg),void *arg)
        d.fn=fn;
        d.arg=arg;
 
-       lh_doall_arg(names_lh,do_all_fn,&d);
+       lh_doall_arg(names_lh,LHASH_DOALL_ARG_FN(do_all_fn),&d);
        }
 
 struct doall_sorted
@@ -284,17 +297,17 @@ void OBJ_NAME_do_all_sorted(int type,void (*fn)(const OBJ_NAME *,void *arg),
        d.n=0;
        OBJ_NAME_do_all(type,do_all_sorted_fn,&d);
 
-       qsort(d.names,d.n,sizeof *d.names,do_all_sorted_cmp);
+       qsort((void *)d.names,d.n,sizeof *d.names,do_all_sorted_cmp);
 
        for(n=0 ; n < d.n ; ++n)
                fn(d.names[n],arg);
 
-       OPENSSL_free(d.names);
+       OPENSSL_free((void *)d.names);
        }
 
 static int free_type;
 
-static void names_lh_free(OBJ_NAME *onp, int type)
+static void names_lh_free(OBJ_NAME *onp)
 {
        if(onp == NULL)
                return;
@@ -305,6 +318,8 @@ static void names_lh_free(OBJ_NAME *onp, int type)
                }
        }
 
+static IMPLEMENT_LHASH_DOALL_FN(names_lh_free, OBJ_NAME *)
+
 static void name_funcs_free(NAME_FUNCS *ptr)
        {
        OPENSSL_free(ptr);
@@ -320,7 +335,7 @@ void OBJ_NAME_cleanup(int type)
        down_load=names_lh->down_load;
        names_lh->down_load=0;
 
-       lh_doall(names_lh,names_lh_free);
+       lh_doall(names_lh,LHASH_DOALL_FN(names_lh_free));
        if (type < 0)
                {
                lh_free(names_lh);