diff options
| author | beck <> | 1999-09-29 04:37:45 +0000 |
|---|---|---|
| committer | beck <> | 1999-09-29 04:37:45 +0000 |
| commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
| tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/lhash | |
| parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
| download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip | |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/lhash')
| -rw-r--r-- | src/lib/libcrypto/lhash/Makefile.ssl | 38 | ||||
| -rw-r--r-- | src/lib/libcrypto/lhash/lh_stats.c | 38 | ||||
| -rw-r--r-- | src/lib/libcrypto/lhash/lh_test.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/lhash/lhash.c | 97 | ||||
| -rw-r--r-- | src/lib/libcrypto/lhash/lhash.h | 33 | ||||
| -rw-r--r-- | src/lib/libcrypto/lhash/num.pl | 2 |
6 files changed, 88 insertions, 122 deletions
diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl index cb08547b4f..cc9ff46b04 100644 --- a/src/lib/libcrypto/lhash/Makefile.ssl +++ b/src/lib/libcrypto/lhash/Makefile.ssl | |||
| @@ -7,9 +7,11 @@ TOP= ../.. | |||
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= | 8 | INCLUDES= |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 10 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
| 11 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
| 12 | MAKEDEPEND= makedepend -f Makefile.ssl | 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) |
| 13 | MAKEFILE= Makefile.ssl | 15 | MAKEFILE= Makefile.ssl |
| 14 | AR= ar r | 16 | AR= ar r |
| 15 | 17 | ||
| @@ -37,24 +39,23 @@ all: lib | |||
| 37 | 39 | ||
| 38 | lib: $(LIBOBJ) | 40 | lib: $(LIBOBJ) |
| 39 | $(AR) $(LIB) $(LIBOBJ) | 41 | $(AR) $(LIB) $(LIBOBJ) |
| 40 | sh $(TOP)/util/ranlib.sh $(LIB) | 42 | $(RANLIB) $(LIB) |
| 41 | @touch lib | 43 | @touch lib |
| 42 | 44 | ||
| 43 | files: | 45 | files: |
| 44 | perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | 46 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO |
| 45 | 47 | ||
| 46 | links: | 48 | links: |
| 47 | /bin/rm -f Makefile | 49 | @$(TOP)/util/point.sh Makefile.ssl Makefile |
| 48 | $(TOP)/util/point.sh Makefile.ssl Makefile ; | 50 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) |
| 49 | $(TOP)/util/mklink.sh ../../include $(EXHEADER) | 51 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) |
| 50 | $(TOP)/util/mklink.sh ../../test $(TEST) | 52 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) |
| 51 | $(TOP)/util/mklink.sh ../../apps $(APPS) | ||
| 52 | 53 | ||
| 53 | install: | 54 | install: |
| 54 | @for i in $(EXHEADER) ; \ | 55 | @for i in $(EXHEADER) ; \ |
| 55 | do \ | 56 | do \ |
| 56 | (cp $$i $(INSTALLTOP)/include/$$i; \ | 57 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ |
| 57 | chmod 644 $(INSTALLTOP)/include/$$i ); \ | 58 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ |
| 58 | done; | 59 | done; |
| 59 | 60 | ||
| 60 | tags: | 61 | tags: |
| @@ -66,15 +67,22 @@ lint: | |||
| 66 | lint -DLINT $(INCLUDES) $(SRC)>fluff | 67 | lint -DLINT $(INCLUDES) $(SRC)>fluff |
| 67 | 68 | ||
| 68 | depend: | 69 | depend: |
| 69 | $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) | 70 | $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) |
| 70 | 71 | ||
| 71 | dclean: | 72 | dclean: |
| 72 | perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | 73 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new |
| 73 | mv -f Makefile.new $(MAKEFILE) | 74 | mv -f Makefile.new $(MAKEFILE) |
| 74 | 75 | ||
| 75 | clean: | 76 | clean: |
| 76 | /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | 77 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff |
| 77 | |||
| 78 | errors: | ||
| 79 | 78 | ||
| 80 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 79 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 80 | |||
| 81 | lh_stats.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 82 | lh_stats.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 83 | lh_stats.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 84 | lh_stats.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 85 | lh_stats.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
| 86 | lh_stats.o: ../cryptlib.h | ||
| 87 | lhash.o: ../../include/openssl/crypto.h ../../include/openssl/lhash.h | ||
| 88 | lhash.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
diff --git a/src/lib/libcrypto/lhash/lh_stats.c b/src/lib/libcrypto/lhash/lh_stats.c index 23fe82f777..80b931c12b 100644 --- a/src/lib/libcrypto/lhash/lh_stats.c +++ b/src/lib/libcrypto/lhash/lh_stats.c | |||
| @@ -63,13 +63,11 @@ | |||
| 63 | * and things should work as expected */ | 63 | * and things should work as expected */ |
| 64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
| 65 | 65 | ||
| 66 | #include "lhash.h" | 66 | #include <openssl/lhash.h> |
| 67 | 67 | ||
| 68 | #ifndef HEADER_BIO_H | 68 | #ifndef HEADER_BIO_H |
| 69 | 69 | ||
| 70 | void lh_stats(lh, out) | 70 | void lh_stats(LHASH *lh, FILE *out) |
| 71 | LHASH *lh; | ||
| 72 | FILE *out; | ||
| 73 | { | 71 | { |
| 74 | fprintf(out,"num_items = %lu\n",lh->num_items); | 72 | fprintf(out,"num_items = %lu\n",lh->num_items); |
| 75 | fprintf(out,"num_nodes = %u\n",lh->num_nodes); | 73 | fprintf(out,"num_nodes = %u\n",lh->num_nodes); |
| @@ -95,9 +93,7 @@ FILE *out; | |||
| 95 | #endif | 93 | #endif |
| 96 | } | 94 | } |
| 97 | 95 | ||
| 98 | void lh_node_stats(lh, out) | 96 | void lh_node_stats(LHASH *lh, FILE *out) |
| 99 | LHASH *lh; | ||
| 100 | FILE *out; | ||
| 101 | { | 97 | { |
| 102 | LHASH_NODE *n; | 98 | LHASH_NODE *n; |
| 103 | unsigned int i,num; | 99 | unsigned int i,num; |
| @@ -110,9 +106,7 @@ FILE *out; | |||
| 110 | } | 106 | } |
| 111 | } | 107 | } |
| 112 | 108 | ||
| 113 | void lh_node_usage_stats(lh, out) | 109 | void lh_node_usage_stats(LHASH *lh, FILE *out) |
| 114 | LHASH *lh; | ||
| 115 | FILE *out; | ||
| 116 | { | 110 | { |
| 117 | LHASH_NODE *n; | 111 | LHASH_NODE *n; |
| 118 | unsigned long num; | 112 | unsigned long num; |
| @@ -142,9 +136,7 @@ FILE *out; | |||
| 142 | #else | 136 | #else |
| 143 | 137 | ||
| 144 | #ifndef NO_FP_API | 138 | #ifndef NO_FP_API |
| 145 | void lh_stats(lh,fp) | 139 | void lh_stats(LHASH *lh, FILE *fp) |
| 146 | LHASH *lh; | ||
| 147 | FILE *fp; | ||
| 148 | { | 140 | { |
| 149 | BIO *bp; | 141 | BIO *bp; |
| 150 | 142 | ||
| @@ -156,9 +148,7 @@ FILE *fp; | |||
| 156 | end:; | 148 | end:; |
| 157 | } | 149 | } |
| 158 | 150 | ||
| 159 | void lh_node_stats(lh,fp) | 151 | void lh_node_stats(LHASH *lh, FILE *fp) |
| 160 | LHASH *lh; | ||
| 161 | FILE *fp; | ||
| 162 | { | 152 | { |
| 163 | BIO *bp; | 153 | BIO *bp; |
| 164 | 154 | ||
| @@ -170,9 +160,7 @@ FILE *fp; | |||
| 170 | end:; | 160 | end:; |
| 171 | } | 161 | } |
| 172 | 162 | ||
| 173 | void lh_node_usage_stats(lh,fp) | 163 | void lh_node_usage_stats(LHASH *lh, FILE *fp) |
| 174 | LHASH *lh; | ||
| 175 | FILE *fp; | ||
| 176 | { | 164 | { |
| 177 | BIO *bp; | 165 | BIO *bp; |
| 178 | 166 | ||
| @@ -186,9 +174,7 @@ end:; | |||
| 186 | 174 | ||
| 187 | #endif | 175 | #endif |
| 188 | 176 | ||
| 189 | void lh_stats_bio(lh, out) | 177 | void lh_stats_bio(LHASH *lh, BIO *out) |
| 190 | LHASH *lh; | ||
| 191 | BIO *out; | ||
| 192 | { | 178 | { |
| 193 | char buf[128]; | 179 | char buf[128]; |
| 194 | 180 | ||
| @@ -236,9 +222,7 @@ BIO *out; | |||
| 236 | #endif | 222 | #endif |
| 237 | } | 223 | } |
| 238 | 224 | ||
| 239 | void lh_node_stats_bio(lh, out) | 225 | void lh_node_stats_bio(LHASH *lh, BIO *out) |
| 240 | LHASH *lh; | ||
| 241 | BIO *out; | ||
| 242 | { | 226 | { |
| 243 | LHASH_NODE *n; | 227 | LHASH_NODE *n; |
| 244 | unsigned int i,num; | 228 | unsigned int i,num; |
| @@ -253,9 +237,7 @@ BIO *out; | |||
| 253 | } | 237 | } |
| 254 | } | 238 | } |
| 255 | 239 | ||
| 256 | void lh_node_usage_stats_bio(lh, out) | 240 | void lh_node_usage_stats_bio(LHASH *lh, BIO *out) |
| 257 | LHASH *lh; | ||
| 258 | BIO *out; | ||
| 259 | { | 241 | { |
| 260 | LHASH_NODE *n; | 242 | LHASH_NODE *n; |
| 261 | unsigned long num; | 243 | unsigned long num; |
diff --git a/src/lib/libcrypto/lhash/lh_test.c b/src/lib/libcrypto/lhash/lh_test.c index 294b42bc82..08138b52c3 100644 --- a/src/lib/libcrypto/lhash/lh_test.c +++ b/src/lib/libcrypto/lhash/lh_test.c | |||
| @@ -59,7 +59,7 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 61 | #include <string.h> | 61 | #include <string.h> |
| 62 | #include "lhash.h" | 62 | #include <openssl/lhash.h> |
| 63 | 63 | ||
| 64 | main() | 64 | main() |
| 65 | { | 65 | { |
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c index 6dfb5c9ccc..801322beb6 100644 --- a/src/lib/libcrypto/lhash/lhash.c +++ b/src/lib/libcrypto/lhash/lhash.c | |||
| @@ -56,11 +56,14 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | char *lh_version="lhash part of SSLeay 0.9.0b 29-Jun-1998"; | ||
| 60 | |||
| 61 | /* Code for dynamic hash table routines | 59 | /* Code for dynamic hash table routines |
| 62 | * Author - Eric Young v 2.0 | 60 | * Author - Eric Young v 2.0 |
| 63 | * | 61 | * |
| 62 | * 2.2 eay - added #include "crypto.h" so the memory leak checking code is | ||
| 63 | * present. eay 18-Jun-98 | ||
| 64 | * | ||
| 65 | * 2.1 eay - Added an 'error in last operation' flag. eay 6-May-98 | ||
| 66 | * | ||
| 64 | * 2.0 eay - Fixed a bug that occured when using lh_delete | 67 | * 2.0 eay - Fixed a bug that occured when using lh_delete |
| 65 | * from inside lh_doall(). As entries were deleted, | 68 | * from inside lh_doall(). As entries were deleted, |
| 66 | * the 'table' was 'contract()ed', making some entries | 69 | * the 'table' was 'contract()ed', making some entries |
| @@ -94,14 +97,16 @@ char *lh_version="lhash part of SSLeay 0.9.0b 29-Jun-1998"; | |||
| 94 | #include <stdio.h> | 97 | #include <stdio.h> |
| 95 | #include <string.h> | 98 | #include <string.h> |
| 96 | #include <stdlib.h> | 99 | #include <stdlib.h> |
| 97 | #include "lhash.h" | 100 | #include <openssl/crypto.h> |
| 101 | #include <openssl/lhash.h> | ||
| 102 | |||
| 103 | const char *lh_version="lhash" OPENSSL_VERSION_PTEXT; | ||
| 98 | 104 | ||
| 99 | #undef MIN_NODES | 105 | #undef MIN_NODES |
| 100 | #define MIN_NODES 16 | 106 | #define MIN_NODES 16 |
| 101 | #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ | 107 | #define UP_LOAD (2*LH_LOAD_MULT) /* load times 256 (default 2) */ |
| 102 | #define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ | 108 | #define DOWN_LOAD (LH_LOAD_MULT) /* load times 256 (default 1) */ |
| 103 | 109 | ||
| 104 | #ifndef NOPROTO | ||
| 105 | 110 | ||
| 106 | #define P_CP char * | 111 | #define P_CP char * |
| 107 | #define P_CPP char *,char * | 112 | #define P_CPP char *,char * |
| @@ -109,26 +114,14 @@ static void expand(LHASH *lh); | |||
| 109 | static void contract(LHASH *lh); | 114 | static void contract(LHASH *lh); |
| 110 | static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash); | 115 | static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash); |
| 111 | 116 | ||
| 112 | #else | 117 | LHASH *lh_new(unsigned long (*h)(), int (*c)()) |
| 113 | |||
| 114 | #define P_CP | ||
| 115 | #define P_CPP | ||
| 116 | static void expand(); | ||
| 117 | static void contract(); | ||
| 118 | static LHASH_NODE **getrn(); | ||
| 119 | |||
| 120 | #endif | ||
| 121 | |||
| 122 | LHASH *lh_new(h, c) | ||
| 123 | unsigned long (*h)(); | ||
| 124 | int (*c)(); | ||
| 125 | { | 118 | { |
| 126 | LHASH *ret; | 119 | LHASH *ret; |
| 127 | int i; | 120 | int i; |
| 128 | 121 | ||
| 129 | if ((ret=(LHASH *)malloc(sizeof(LHASH))) == NULL) | 122 | if ((ret=(LHASH *)Malloc(sizeof(LHASH))) == NULL) |
| 130 | goto err0; | 123 | goto err0; |
| 131 | if ((ret->b=(LHASH_NODE **)malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL) | 124 | if ((ret->b=(LHASH_NODE **)Malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL) |
| 132 | goto err1; | 125 | goto err1; |
| 133 | for (i=0; i<MIN_NODES; i++) | 126 | for (i=0; i<MIN_NODES; i++) |
| 134 | ret->b[i]=NULL; | 127 | ret->b[i]=NULL; |
| @@ -156,41 +149,43 @@ int (*c)(); | |||
| 156 | ret->num_retrieve_miss=0; | 149 | ret->num_retrieve_miss=0; |
| 157 | ret->num_hash_comps=0; | 150 | ret->num_hash_comps=0; |
| 158 | 151 | ||
| 152 | ret->error=0; | ||
| 159 | return(ret); | 153 | return(ret); |
| 160 | err1: | 154 | err1: |
| 161 | free((char *)ret); | 155 | Free((char *)ret); |
| 162 | err0: | 156 | err0: |
| 163 | return(NULL); | 157 | return(NULL); |
| 164 | } | 158 | } |
| 165 | 159 | ||
| 166 | void lh_free(lh) | 160 | void lh_free(LHASH *lh) |
| 167 | LHASH *lh; | ||
| 168 | { | 161 | { |
| 169 | unsigned int i; | 162 | unsigned int i; |
| 170 | LHASH_NODE *n,*nn; | 163 | LHASH_NODE *n,*nn; |
| 171 | 164 | ||
| 165 | if(lh == NULL) | ||
| 166 | return; | ||
| 167 | |||
| 172 | for (i=0; i<lh->num_nodes; i++) | 168 | for (i=0; i<lh->num_nodes; i++) |
| 173 | { | 169 | { |
| 174 | n=lh->b[i]; | 170 | n=lh->b[i]; |
| 175 | while (n != NULL) | 171 | while (n != NULL) |
| 176 | { | 172 | { |
| 177 | nn=n->next; | 173 | nn=n->next; |
| 178 | free(n); | 174 | Free(n); |
| 179 | n=nn; | 175 | n=nn; |
| 180 | } | 176 | } |
| 181 | } | 177 | } |
| 182 | free((char *)lh->b); | 178 | Free((char *)lh->b); |
| 183 | free((char *)lh); | 179 | Free((char *)lh); |
| 184 | } | 180 | } |
| 185 | 181 | ||
| 186 | char *lh_insert(lh, data) | 182 | char *lh_insert(LHASH *lh, char *data) |
| 187 | LHASH *lh; | ||
| 188 | char *data; | ||
| 189 | { | 183 | { |
| 190 | unsigned long hash; | 184 | unsigned long hash; |
| 191 | LHASH_NODE *nn,**rn; | 185 | LHASH_NODE *nn,**rn; |
| 192 | char *ret; | 186 | char *ret; |
| 193 | 187 | ||
| 188 | lh->error=0; | ||
| 194 | if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)) | 189 | if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)) |
| 195 | expand(lh); | 190 | expand(lh); |
| 196 | 191 | ||
| @@ -198,8 +193,11 @@ char *data; | |||
| 198 | 193 | ||
| 199 | if (*rn == NULL) | 194 | if (*rn == NULL) |
| 200 | { | 195 | { |
| 201 | if ((nn=(LHASH_NODE *)malloc(sizeof(LHASH_NODE))) == NULL) | 196 | if ((nn=(LHASH_NODE *)Malloc(sizeof(LHASH_NODE))) == NULL) |
| 197 | { | ||
| 198 | lh->error++; | ||
| 202 | return(NULL); | 199 | return(NULL); |
| 200 | } | ||
| 203 | nn->data=data; | 201 | nn->data=data; |
| 204 | nn->next=NULL; | 202 | nn->next=NULL; |
| 205 | #ifndef NO_HASH_COMP | 203 | #ifndef NO_HASH_COMP |
| @@ -219,14 +217,13 @@ char *data; | |||
| 219 | return(ret); | 217 | return(ret); |
| 220 | } | 218 | } |
| 221 | 219 | ||
| 222 | char *lh_delete(lh, data) | 220 | char *lh_delete(LHASH *lh, char *data) |
| 223 | LHASH *lh; | ||
| 224 | char *data; | ||
| 225 | { | 221 | { |
| 226 | unsigned long hash; | 222 | unsigned long hash; |
| 227 | LHASH_NODE *nn,**rn; | 223 | LHASH_NODE *nn,**rn; |
| 228 | char *ret; | 224 | char *ret; |
| 229 | 225 | ||
| 226 | lh->error=0; | ||
| 230 | rn=getrn(lh,data,&hash); | 227 | rn=getrn(lh,data,&hash); |
| 231 | 228 | ||
| 232 | if (*rn == NULL) | 229 | if (*rn == NULL) |
| @@ -239,7 +236,7 @@ char *data; | |||
| 239 | nn= *rn; | 236 | nn= *rn; |
| 240 | *rn=nn->next; | 237 | *rn=nn->next; |
| 241 | ret=nn->data; | 238 | ret=nn->data; |
| 242 | free((char *)nn); | 239 | Free((char *)nn); |
| 243 | lh->num_delete++; | 240 | lh->num_delete++; |
| 244 | } | 241 | } |
| 245 | 242 | ||
| @@ -251,14 +248,13 @@ char *data; | |||
| 251 | return(ret); | 248 | return(ret); |
| 252 | } | 249 | } |
| 253 | 250 | ||
| 254 | char *lh_retrieve(lh, data) | 251 | char *lh_retrieve(LHASH *lh, char *data) |
| 255 | LHASH *lh; | ||
| 256 | char *data; | ||
| 257 | { | 252 | { |
| 258 | unsigned long hash; | 253 | unsigned long hash; |
| 259 | LHASH_NODE **rn; | 254 | LHASH_NODE **rn; |
| 260 | char *ret; | 255 | char *ret; |
| 261 | 256 | ||
| 257 | lh->error=0; | ||
| 262 | rn=getrn(lh,data,&hash); | 258 | rn=getrn(lh,data,&hash); |
| 263 | 259 | ||
| 264 | if (*rn == NULL) | 260 | if (*rn == NULL) |
| @@ -274,17 +270,12 @@ char *data; | |||
| 274 | return(ret); | 270 | return(ret); |
| 275 | } | 271 | } |
| 276 | 272 | ||
| 277 | void lh_doall(lh, func) | 273 | void lh_doall(LHASH *lh, void (*func)()) |
| 278 | LHASH *lh; | ||
| 279 | void (*func)(); | ||
| 280 | { | 274 | { |
| 281 | lh_doall_arg(lh,func,NULL); | 275 | lh_doall_arg(lh,func,NULL); |
| 282 | } | 276 | } |
| 283 | 277 | ||
| 284 | void lh_doall_arg(lh, func, arg) | 278 | void lh_doall_arg(LHASH *lh, void (*func)(), char *arg) |
| 285 | LHASH *lh; | ||
| 286 | void (*func)(); | ||
| 287 | char *arg; | ||
| 288 | { | 279 | { |
| 289 | int i; | 280 | int i; |
| 290 | LHASH_NODE *a,*n; | 281 | LHASH_NODE *a,*n; |
| @@ -305,8 +296,7 @@ char *arg; | |||
| 305 | } | 296 | } |
| 306 | } | 297 | } |
| 307 | 298 | ||
| 308 | static void expand(lh) | 299 | static void expand(LHASH *lh) |
| 309 | LHASH *lh; | ||
| 310 | { | 300 | { |
| 311 | LHASH_NODE **n,**n1,**n2,*np; | 301 | LHASH_NODE **n,**n1,**n2,*np; |
| 312 | unsigned int p,i,j; | 302 | unsigned int p,i,j; |
| @@ -342,11 +332,12 @@ LHASH *lh; | |||
| 342 | if ((lh->p) >= lh->pmax) | 332 | if ((lh->p) >= lh->pmax) |
| 343 | { | 333 | { |
| 344 | j=(int)lh->num_alloc_nodes*2; | 334 | j=(int)lh->num_alloc_nodes*2; |
| 345 | n=(LHASH_NODE **)realloc((char *)lh->b, | 335 | n=(LHASH_NODE **)Realloc((char *)lh->b, |
| 346 | (unsigned int)sizeof(LHASH_NODE *)*j); | 336 | (unsigned int)sizeof(LHASH_NODE *)*j); |
| 347 | if (n == NULL) | 337 | if (n == NULL) |
| 348 | { | 338 | { |
| 349 | /* fputs("realloc error in lhash",stderr); */ | 339 | /* fputs("realloc error in lhash",stderr); */ |
| 340 | lh->error++; | ||
| 350 | lh->p=0; | 341 | lh->p=0; |
| 351 | return; | 342 | return; |
| 352 | } | 343 | } |
| @@ -361,8 +352,7 @@ LHASH *lh; | |||
| 361 | } | 352 | } |
| 362 | } | 353 | } |
| 363 | 354 | ||
| 364 | static void contract(lh) | 355 | static void contract(LHASH *lh) |
| 365 | LHASH *lh; | ||
| 366 | { | 356 | { |
| 367 | LHASH_NODE **n,*n1,*np; | 357 | LHASH_NODE **n,*n1,*np; |
| 368 | 358 | ||
| @@ -370,11 +360,12 @@ LHASH *lh; | |||
| 370 | lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */ | 360 | lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */ |
| 371 | if (lh->p == 0) | 361 | if (lh->p == 0) |
| 372 | { | 362 | { |
| 373 | n=(LHASH_NODE **)realloc((char *)lh->b, | 363 | n=(LHASH_NODE **)Realloc((char *)lh->b, |
| 374 | (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax)); | 364 | (unsigned int)(sizeof(LHASH_NODE *)*lh->pmax)); |
| 375 | if (n == NULL) | 365 | if (n == NULL) |
| 376 | { | 366 | { |
| 377 | /* fputs("realloc error in lhash",stderr); */ | 367 | /* fputs("realloc error in lhash",stderr); */ |
| 368 | lh->error++; | ||
| 378 | return; | 369 | return; |
| 379 | } | 370 | } |
| 380 | lh->num_contract_reallocs++; | 371 | lh->num_contract_reallocs++; |
| @@ -400,10 +391,7 @@ LHASH *lh; | |||
| 400 | } | 391 | } |
| 401 | } | 392 | } |
| 402 | 393 | ||
| 403 | static LHASH_NODE **getrn(lh, data, rhash) | 394 | static LHASH_NODE **getrn(LHASH *lh, char *data, unsigned long *rhash) |
| 404 | LHASH *lh; | ||
| 405 | char *data; | ||
| 406 | unsigned long *rhash; | ||
| 407 | { | 395 | { |
| 408 | LHASH_NODE **ret,*n1; | 396 | LHASH_NODE **ret,*n1; |
| 409 | unsigned long hash,nn; | 397 | unsigned long hash,nn; |
| @@ -457,8 +445,7 @@ char *str; | |||
| 457 | * no collisions on /usr/dict/words and it distributes on %2^n quite | 445 | * no collisions on /usr/dict/words and it distributes on %2^n quite |
| 458 | * well, not as good as MD5, but still good. | 446 | * well, not as good as MD5, but still good. |
| 459 | */ | 447 | */ |
| 460 | unsigned long lh_strhash(c) | 448 | unsigned long lh_strhash(const char *c) |
| 461 | char *c; | ||
| 462 | { | 449 | { |
| 463 | unsigned long ret=0; | 450 | unsigned long ret=0; |
| 464 | long n; | 451 | long n; |
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h index 70cbc6dfe7..6e5a1fe708 100644 --- a/src/lib/libcrypto/lhash/lhash.h +++ b/src/lib/libcrypto/lhash/lhash.h | |||
| @@ -67,6 +67,10 @@ | |||
| 67 | extern "C" { | 67 | extern "C" { |
| 68 | #endif | 68 | #endif |
| 69 | 69 | ||
| 70 | #ifndef NO_FP_API | ||
| 71 | #include <stdio.h> | ||
| 72 | #endif | ||
| 73 | |||
| 70 | typedef struct lhash_node_st | 74 | typedef struct lhash_node_st |
| 71 | { | 75 | { |
| 72 | char *data; | 76 | char *data; |
| @@ -102,11 +106,16 @@ typedef struct lhash_st | |||
| 102 | unsigned long num_retrieve; | 106 | unsigned long num_retrieve; |
| 103 | unsigned long num_retrieve_miss; | 107 | unsigned long num_retrieve_miss; |
| 104 | unsigned long num_hash_comps; | 108 | unsigned long num_hash_comps; |
| 109 | |||
| 110 | int error; | ||
| 105 | } LHASH; | 111 | } LHASH; |
| 106 | 112 | ||
| 107 | #define LH_LOAD_MULT 256 | 113 | #define LH_LOAD_MULT 256 |
| 108 | 114 | ||
| 109 | #ifndef NOPROTO | 115 | /* Indicates a malloc() error in the last call, this is only bad |
| 116 | * in lh_insert(). */ | ||
| 117 | #define lh_error(lh) ((lh)->error) | ||
| 118 | |||
| 110 | LHASH *lh_new(unsigned long (*h)(), int (*c)()); | 119 | LHASH *lh_new(unsigned long (*h)(), int (*c)()); |
| 111 | void lh_free(LHASH *lh); | 120 | void lh_free(LHASH *lh); |
| 112 | char *lh_insert(LHASH *lh, char *data); | 121 | char *lh_insert(LHASH *lh, char *data); |
| @@ -114,7 +123,7 @@ char *lh_delete(LHASH *lh, char *data); | |||
| 114 | char *lh_retrieve(LHASH *lh, char *data); | 123 | char *lh_retrieve(LHASH *lh, char *data); |
| 115 | void lh_doall(LHASH *lh, void (*func)(/* char *b */)); | 124 | void lh_doall(LHASH *lh, void (*func)(/* char *b */)); |
| 116 | void lh_doall_arg(LHASH *lh, void (*func)(/*char *a,char *b*/),char *arg); | 125 | void lh_doall_arg(LHASH *lh, void (*func)(/*char *a,char *b*/),char *arg); |
| 117 | unsigned long lh_strhash(char *c); | 126 | unsigned long lh_strhash(const char *c); |
| 118 | 127 | ||
| 119 | #ifndef NO_FP_API | 128 | #ifndef NO_FP_API |
| 120 | void lh_stats(LHASH *lh, FILE *out); | 129 | void lh_stats(LHASH *lh, FILE *out); |
| @@ -127,26 +136,6 @@ void lh_stats_bio(LHASH *lh, BIO *out); | |||
| 127 | void lh_node_stats_bio(LHASH *lh, BIO *out); | 136 | void lh_node_stats_bio(LHASH *lh, BIO *out); |
| 128 | void lh_node_usage_stats_bio(LHASH *lh, BIO *out); | 137 | void lh_node_usage_stats_bio(LHASH *lh, BIO *out); |
| 129 | #endif | 138 | #endif |
| 130 | #else | ||
| 131 | LHASH *lh_new(); | ||
| 132 | void lh_free(); | ||
| 133 | char *lh_insert(); | ||
| 134 | char *lh_delete(); | ||
| 135 | char *lh_retrieve(); | ||
| 136 | void lh_doall(); | ||
| 137 | void lh_doall_arg(); | ||
| 138 | unsigned long lh_strhash(); | ||
| 139 | |||
| 140 | #ifndef NO_FP_API | ||
| 141 | void lh_stats(); | ||
| 142 | void lh_node_stats(); | ||
| 143 | void lh_node_usage_stats(); | ||
| 144 | #endif | ||
| 145 | void lh_stats_bio(); | ||
| 146 | void lh_node_stats_bio(); | ||
| 147 | void lh_node_usage_stats_bio(); | ||
| 148 | #endif | ||
| 149 | |||
| 150 | #ifdef __cplusplus | 139 | #ifdef __cplusplus |
| 151 | } | 140 | } |
| 152 | #endif | 141 | #endif |
diff --git a/src/lib/libcrypto/lhash/num.pl b/src/lib/libcrypto/lhash/num.pl index 4d937c1f90..30fedf9cd5 100644 --- a/src/lib/libcrypto/lhash/num.pl +++ b/src/lib/libcrypto/lhash/num.pl | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/perl | 1 | #!/usr/local/bin/perl |
| 2 | 2 | ||
| 3 | #node 10 -> 4 | 3 | #node 10 -> 4 |
| 4 | 4 | ||
