X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Flhash%2Flhash.c;h=801322beb640fd858887bb988147f19c8993ac6e;hb=023c8d0b0aec445b680ef5aea2bd2154adb59974;hp=c8c29a8d305d1806423a16c8edb85adc9241a2bd;hpb=9cb0969f657bcc297430fefb9a51e78c52703121;p=oweals%2Fopenssl.git diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index c8c29a8d30..801322beb6 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -56,8 +56,6 @@ * [including the GNU Public Licence.] */ -char *lh_version="lhash part of OpenSSL 0.9.2 31-Dec-1998"; - /* Code for dynamic hash table routines * Author - Eric Young v 2.0 * @@ -99,15 +97,16 @@ char *lh_version="lhash part of OpenSSL 0.9.2 31-Dec-1998"; #include #include #include -#include "crypto.h" -#include "lhash.h" +#include +#include + +const char *lh_version="lhash" OPENSSL_VERSION_PTEXT; #undef MIN_NODES #define MIN_NODES 16 #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ #define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ -#ifndef NOPROTO #define P_CP char * #define P_CPP char *,char * @@ -115,19 +114,7 @@ static void expand(LHASH *lh); static void contract(LHASH *lh); static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash); -#else - -#define P_CP -#define P_CPP -static void expand(); -static void contract(); -static LHASH_NODE **getrn(); - -#endif - -LHASH *lh_new(h, c) -unsigned long (*h)(); -int (*c)(); +LHASH *lh_new(unsigned long (*h)(), int (*c)()) { LHASH *ret; int i; @@ -170,12 +157,14 @@ err0: return(NULL); } -void lh_free(lh) -LHASH *lh; +void lh_free(LHASH *lh) { unsigned int i; LHASH_NODE *n,*nn; + if(lh == NULL) + return; + for (i=0; inum_nodes; i++) { n=lh->b[i]; @@ -190,9 +179,7 @@ LHASH *lh; Free((char *)lh); } -char *lh_insert(lh, data) -LHASH *lh; -char *data; +char *lh_insert(LHASH *lh, char *data) { unsigned long hash; LHASH_NODE *nn,**rn; @@ -230,9 +217,7 @@ char *data; return(ret); } -char *lh_delete(lh, data) -LHASH *lh; -char *data; +char *lh_delete(LHASH *lh, char *data) { unsigned long hash; LHASH_NODE *nn,**rn; @@ -263,9 +248,7 @@ char *data; return(ret); } -char *lh_retrieve(lh, data) -LHASH *lh; -char *data; +char *lh_retrieve(LHASH *lh, char *data) { unsigned long hash; LHASH_NODE **rn; @@ -287,17 +270,12 @@ char *data; return(ret); } -void lh_doall(lh, func) -LHASH *lh; -void (*func)(); +void lh_doall(LHASH *lh, void (*func)()) { lh_doall_arg(lh,func,NULL); } -void lh_doall_arg(lh, func, arg) -LHASH *lh; -void (*func)(); -char *arg; +void lh_doall_arg(LHASH *lh, void (*func)(), char *arg) { int i; LHASH_NODE *a,*n; @@ -318,8 +296,7 @@ char *arg; } } -static void expand(lh) -LHASH *lh; +static void expand(LHASH *lh) { LHASH_NODE **n,**n1,**n2,*np; unsigned int p,i,j; @@ -375,8 +352,7 @@ LHASH *lh; } } -static void contract(lh) -LHASH *lh; +static void contract(LHASH *lh) { LHASH_NODE **n,*n1,*np; @@ -415,10 +391,7 @@ LHASH *lh; } } -static LHASH_NODE **getrn(lh, data, rhash) -LHASH *lh; -char *data; -unsigned long *rhash; +static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash) { LHASH_NODE **ret,*n1; unsigned long hash,nn; @@ -472,8 +445,7 @@ char *str; * no collisions on /usr/dict/words and it distributes on %2^n quite * well, not as good as MD5, but still good. */ -unsigned long lh_strhash(c) -char *c; +unsigned long lh_strhash(const char *c) { unsigned long ret=0; long n;