New functions to enumerate digests and ciphers.
[openssl.git] / crypto / lhash / lhash.c
index 0a16fcf27d58904b26a556e044c92b453d13d87e..373c72dcb6f301c473cb1e35eae327dc3b1bd917 100644 (file)
@@ -176,11 +176,11 @@ void lh_free(LHASH *lh)
        OPENSSL_free(lh);
        }
 
-void *lh_insert(LHASH *lh, const void *data)
+void *lh_insert(LHASH *lh, void *data)
        {
        unsigned long hash;
        LHASH_NODE *nn,**rn;
-       const void *ret;
+       void *ret;
 
        lh->error=0;
        if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))
@@ -211,14 +211,14 @@ void *lh_insert(LHASH *lh, const void *data)
                (*rn)->data=data;
                lh->num_replace++;
                }
-       return((void *)ret);
+       return(ret);
        }
 
 void *lh_delete(LHASH *lh, const void *data)
        {
        unsigned long hash;
        LHASH_NODE *nn,**rn;
-       const void *ret;
+       void *ret;
 
        lh->error=0;
        rn=getrn(lh,data,&hash);
@@ -242,14 +242,14 @@ void *lh_delete(LHASH *lh, const void *data)
                (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))
                contract(lh);
 
-       return((void *)ret);
+       return(ret);
        }
 
 void *lh_retrieve(LHASH *lh, const void *data)
        {
        unsigned long hash;
        LHASH_NODE **rn;
-       const void *ret;
+       void *ret;
 
        lh->error=0;
        rn=getrn(lh,data,&hash);
@@ -264,7 +264,7 @@ void *lh_retrieve(LHASH *lh, const void *data)
                ret= (*rn)->data;
                lh->num_retrieve++;
                }
-       return((void *)ret);
+       return(ret);
        }
 
 static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
@@ -273,6 +273,9 @@ static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
        int i;
        LHASH_NODE *a,*n;
 
+       if (lh == NULL)
+               return;
+
        /* reverse the order so we search from 'top to bottom'
         * We were having memory leaks otherwise */
        for (i=lh->num_nodes-1; i>=0; i--)
@@ -339,7 +342,7 @@ static void expand(LHASH *lh)
                {
                j=(int)lh->num_alloc_nodes*2;
                n=(LHASH_NODE **)OPENSSL_realloc(lh->b,
-                       (unsigned int)sizeof(LHASH_NODE *)*j);
+                       (int)(sizeof(LHASH_NODE *)*j));
                if (n == NULL)
                        {
 /*                     fputs("realloc error in lhash",stderr); */
@@ -401,7 +404,7 @@ static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash)
        {
        LHASH_NODE **ret,*n1;
        unsigned long hash,nn;
-       int (*cf)();
+       LHASH_COMP_FN_TYPE cf;
 
        hash=(*(lh->hash))(data);
        lh->num_hash_calls++;