diff options
Diffstat (limited to 'src/lib/libcrypto/lhash')
-rw-r--r-- | src/lib/libcrypto/lhash/lhash.c | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/lhash/lhash.h | 17 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c index 0a16fcf27d..04ea80203c 100644 --- a/src/lib/libcrypto/lhash/lhash.c +++ b/src/lib/libcrypto/lhash/lhash.c | |||
@@ -100,7 +100,7 @@ | |||
100 | #include <openssl/crypto.h> | 100 | #include <openssl/crypto.h> |
101 | #include <openssl/lhash.h> | 101 | #include <openssl/lhash.h> |
102 | 102 | ||
103 | const char *lh_version="lhash" OPENSSL_VERSION_PTEXT; | 103 | const char lh_version[]="lhash" OPENSSL_VERSION_PTEXT; |
104 | 104 | ||
105 | #undef MIN_NODES | 105 | #undef MIN_NODES |
106 | #define MIN_NODES 16 | 106 | #define MIN_NODES 16 |
@@ -176,11 +176,11 @@ void lh_free(LHASH *lh) | |||
176 | OPENSSL_free(lh); | 176 | OPENSSL_free(lh); |
177 | } | 177 | } |
178 | 178 | ||
179 | void *lh_insert(LHASH *lh, const void *data) | 179 | void *lh_insert(LHASH *lh, void *data) |
180 | { | 180 | { |
181 | unsigned long hash; | 181 | unsigned long hash; |
182 | LHASH_NODE *nn,**rn; | 182 | LHASH_NODE *nn,**rn; |
183 | const void *ret; | 183 | void *ret; |
184 | 184 | ||
185 | lh->error=0; | 185 | lh->error=0; |
186 | if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)) | 186 | 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) | |||
211 | (*rn)->data=data; | 211 | (*rn)->data=data; |
212 | lh->num_replace++; | 212 | lh->num_replace++; |
213 | } | 213 | } |
214 | return((void *)ret); | 214 | return(ret); |
215 | } | 215 | } |
216 | 216 | ||
217 | void *lh_delete(LHASH *lh, const void *data) | 217 | void *lh_delete(LHASH *lh, const void *data) |
218 | { | 218 | { |
219 | unsigned long hash; | 219 | unsigned long hash; |
220 | LHASH_NODE *nn,**rn; | 220 | LHASH_NODE *nn,**rn; |
221 | const void *ret; | 221 | void *ret; |
222 | 222 | ||
223 | lh->error=0; | 223 | lh->error=0; |
224 | rn=getrn(lh,data,&hash); | 224 | rn=getrn(lh,data,&hash); |
@@ -242,14 +242,14 @@ void *lh_delete(LHASH *lh, const void *data) | |||
242 | (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))) | 242 | (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))) |
243 | contract(lh); | 243 | contract(lh); |
244 | 244 | ||
245 | return((void *)ret); | 245 | return(ret); |
246 | } | 246 | } |
247 | 247 | ||
248 | void *lh_retrieve(LHASH *lh, const void *data) | 248 | void *lh_retrieve(LHASH *lh, const void *data) |
249 | { | 249 | { |
250 | unsigned long hash; | 250 | unsigned long hash; |
251 | LHASH_NODE **rn; | 251 | LHASH_NODE **rn; |
252 | const void *ret; | 252 | void *ret; |
253 | 253 | ||
254 | lh->error=0; | 254 | lh->error=0; |
255 | rn=getrn(lh,data,&hash); | 255 | rn=getrn(lh,data,&hash); |
@@ -264,7 +264,7 @@ void *lh_retrieve(LHASH *lh, const void *data) | |||
264 | ret= (*rn)->data; | 264 | ret= (*rn)->data; |
265 | lh->num_retrieve++; | 265 | lh->num_retrieve++; |
266 | } | 266 | } |
267 | return((void *)ret); | 267 | return(ret); |
268 | } | 268 | } |
269 | 269 | ||
270 | static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func, | 270 | static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func, |
@@ -339,7 +339,7 @@ static void expand(LHASH *lh) | |||
339 | { | 339 | { |
340 | j=(int)lh->num_alloc_nodes*2; | 340 | j=(int)lh->num_alloc_nodes*2; |
341 | n=(LHASH_NODE **)OPENSSL_realloc(lh->b, | 341 | n=(LHASH_NODE **)OPENSSL_realloc(lh->b, |
342 | (unsigned int)sizeof(LHASH_NODE *)*j); | 342 | (int)(sizeof(LHASH_NODE *)*j)); |
343 | if (n == NULL) | 343 | if (n == NULL) |
344 | { | 344 | { |
345 | /* fputs("realloc error in lhash",stderr); */ | 345 | /* fputs("realloc error in lhash",stderr); */ |
@@ -401,7 +401,7 @@ static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash) | |||
401 | { | 401 | { |
402 | LHASH_NODE **ret,*n1; | 402 | LHASH_NODE **ret,*n1; |
403 | unsigned long hash,nn; | 403 | unsigned long hash,nn; |
404 | int (*cf)(); | 404 | LHASH_COMP_FN_TYPE cf; |
405 | 405 | ||
406 | hash=(*(lh->hash))(data); | 406 | hash=(*(lh->hash))(data); |
407 | lh->num_hash_calls++; | 407 | lh->num_hash_calls++; |
diff --git a/src/lib/libcrypto/lhash/lhash.h b/src/lib/libcrypto/lhash/lhash.h index dee8207333..d392d0cd80 100644 --- a/src/lib/libcrypto/lhash/lhash.h +++ b/src/lib/libcrypto/lhash/lhash.h | |||
@@ -63,6 +63,7 @@ | |||
63 | #ifndef HEADER_LHASH_H | 63 | #ifndef HEADER_LHASH_H |
64 | #define HEADER_LHASH_H | 64 | #define HEADER_LHASH_H |
65 | 65 | ||
66 | #include <openssl/e_os2.h> | ||
66 | #ifndef OPENSSL_NO_FP_API | 67 | #ifndef OPENSSL_NO_FP_API |
67 | #include <stdio.h> | 68 | #include <stdio.h> |
68 | #endif | 69 | #endif |
@@ -77,7 +78,7 @@ extern "C" { | |||
77 | 78 | ||
78 | typedef struct lhash_node_st | 79 | typedef struct lhash_node_st |
79 | { | 80 | { |
80 | const void *data; | 81 | void *data; |
81 | struct lhash_node_st *next; | 82 | struct lhash_node_st *next; |
82 | #ifndef OPENSSL_NO_HASH_COMP | 83 | #ifndef OPENSSL_NO_HASH_COMP |
83 | unsigned long hash; | 84 | unsigned long hash; |
@@ -86,8 +87,8 @@ typedef struct lhash_node_st | |||
86 | 87 | ||
87 | typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); | 88 | typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); |
88 | typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); | 89 | typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); |
89 | typedef void (*LHASH_DOALL_FN_TYPE)(const void *); | 90 | typedef void (*LHASH_DOALL_FN_TYPE)(void *); |
90 | typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, void *); | 91 | typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); |
91 | 92 | ||
92 | /* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. | 93 | /* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. |
93 | * This way, callbacks can be provided to LHASH structures without function | 94 | * This way, callbacks can be provided to LHASH structures without function |
@@ -117,18 +118,18 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, void *); | |||
117 | 118 | ||
118 | /* Third: "doall" functions */ | 119 | /* Third: "doall" functions */ |
119 | #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ | 120 | #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \ |
120 | void f_name##_LHASH_DOALL(const void *); | 121 | void f_name##_LHASH_DOALL(void *); |
121 | #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ | 122 | #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \ |
122 | void f_name##_LHASH_DOALL(const void *arg) { \ | 123 | void f_name##_LHASH_DOALL(void *arg) { \ |
123 | o_type a = (o_type)arg; \ | 124 | o_type a = (o_type)arg; \ |
124 | f_name(a); } | 125 | f_name(a); } |
125 | #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL | 126 | #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL |
126 | 127 | ||
127 | /* Fourth: "doall_arg" functions */ | 128 | /* Fourth: "doall_arg" functions */ |
128 | #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ | 129 | #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ |
129 | void f_name##_LHASH_DOALL_ARG(const void *, void *); | 130 | void f_name##_LHASH_DOALL_ARG(void *, void *); |
130 | #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ | 131 | #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \ |
131 | void f_name##_LHASH_DOALL_ARG(const void *arg1, void *arg2) { \ | 132 | void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ |
132 | o_type a = (o_type)arg1; \ | 133 | o_type a = (o_type)arg1; \ |
133 | a_type b = (a_type)arg2; \ | 134 | a_type b = (a_type)arg2; \ |
134 | f_name(a,b); } | 135 | f_name(a,b); } |
@@ -172,7 +173,7 @@ typedef struct lhash_st | |||
172 | 173 | ||
173 | LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); | 174 | LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); |
174 | void lh_free(LHASH *lh); | 175 | void lh_free(LHASH *lh); |
175 | void *lh_insert(LHASH *lh, const void *data); | 176 | void *lh_insert(LHASH *lh, void *data); |
176 | void *lh_delete(LHASH *lh, const void *data); | 177 | void *lh_delete(LHASH *lh, const void *data); |
177 | void *lh_retrieve(LHASH *lh, const void *data); | 178 | void *lh_retrieve(LHASH *lh, const void *data); |
178 | void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); | 179 | void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); |