diff options
author | Richard Levitte <levitte@openssl.org> | 2000-12-13 17:15:03 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-12-13 17:15:03 +0000 |
commit | 8d28d5f81b81f68a69db1c67e24bcfc092614346 (patch) | |
tree | 3391f9ea36d1b9655ffd8e9065de14a5284c5556 /crypto/lhash | |
parent | 53b407da84909dffb54c44dc8a1106723a23a546 (diff) |
Constification of the data of a hash table. This means the callback
functions need to be constified, and therefore meant a number of easy
changes a little everywhere.
Now, if someone could explain to me why OBJ_dup() cheats...
Diffstat (limited to 'crypto/lhash')
-rw-r--r-- | crypto/lhash/lhash.c | 24 | ||||
-rw-r--r-- | crypto/lhash/lhash.h | 26 |
2 files changed, 25 insertions, 25 deletions
diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index 60699f45cc..874647af6b 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -109,7 +109,7 @@ const char *lh_version="lhash" OPENSSL_VERSION_PTEXT; static void expand(LHASH *lh); static void contract(LHASH *lh); -static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash); +static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash); LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c) { @@ -176,11 +176,11 @@ void lh_free(LHASH *lh) OPENSSL_free(lh); } -void *lh_insert(LHASH *lh, void *data) +void *lh_insert(LHASH *lh, const void *data) { unsigned long hash; LHASH_NODE *nn,**rn; - void *ret; + const 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, void *data) (*rn)->data=data; lh->num_replace++; } - return(ret); + return((void *)ret); } -void *lh_delete(LHASH *lh, void *data) +void *lh_delete(LHASH *lh, const void *data) { unsigned long hash; LHASH_NODE *nn,**rn; - void *ret; + const void *ret; lh->error=0; rn=getrn(lh,data,&hash); @@ -242,14 +242,14 @@ void *lh_delete(LHASH *lh, void *data) (lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))) contract(lh); - return(ret); + return((void *)ret); } -void *lh_retrieve(LHASH *lh, void *data) +void *lh_retrieve(LHASH *lh, const void *data) { unsigned long hash; LHASH_NODE **rn; - void *ret; + const void *ret; lh->error=0; rn=getrn(lh,data,&hash); @@ -264,7 +264,7 @@ void *lh_retrieve(LHASH *lh, void *data) ret= (*rn)->data; lh->num_retrieve++; } - return(ret); + return((void *)ret); } void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func) @@ -279,7 +279,7 @@ void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func) lh_doall_arg(lh, (LHASH_DOALL_ARG_FN_TYPE)func, NULL); } -void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg) +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, const void *arg) { int i; LHASH_NODE *a,*n; @@ -395,7 +395,7 @@ static void contract(LHASH *lh) } } -static LHASH_NODE **getrn(LHASH *lh, void *data, unsigned long *rhash) +static LHASH_NODE **getrn(LHASH *lh, const void *data, unsigned long *rhash) { LHASH_NODE **ret,*n1; unsigned long hash,nn; diff --git a/crypto/lhash/lhash.h b/crypto/lhash/lhash.h index 6420512079..3c5355885f 100644 --- a/crypto/lhash/lhash.h +++ b/crypto/lhash/lhash.h @@ -77,17 +77,17 @@ extern "C" { typedef struct lhash_node_st { - void *data; + const void *data; struct lhash_node_st *next; #ifndef NO_HASH_COMP unsigned long hash; #endif } LHASH_NODE; -typedef int (*LHASH_COMP_FN_TYPE)(void *, void *); -typedef unsigned long (*LHASH_HASH_FN_TYPE)(void *); -typedef void (*LHASH_DOALL_FN_TYPE)(void *); -typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); +typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *); +typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *); +typedef void (*LHASH_DOALL_FN_TYPE)(const void *); +typedef void (*LHASH_DOALL_ARG_FN_TYPE)(const void *, const void *); /* Macros for declaring and implementing type-safe wrappers for LHASH callbacks. * This way, callbacks can be provided to LHASH structures without function @@ -98,18 +98,18 @@ typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *); /* First: "hash" functions */ #define DECLARE_LHASH_HASH_FN(f_name,o_type) \ - unsigned long f_name##_LHASH_HASH(void *); + unsigned long f_name##_LHASH_HASH(const void *); #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \ - unsigned long f_name##_LHASH_HASH(void *arg) { \ + unsigned long f_name##_LHASH_HASH(const void *arg) { \ o_type a = (o_type)arg; \ return f_name(a); } #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH /* Second: "compare" functions */ #define DECLARE_LHASH_COMP_FN(f_name,o_type) \ - int f_name##_LHASH_COMP(void *, void *); + int f_name##_LHASH_COMP(const void *, const void *); #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \ - int f_name##_LHASH_COMP(void *arg1, void *arg2) { \ + int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \ o_type a = (o_type)arg1; \ o_type b = (o_type)arg2; \ return f_name(a,b); } @@ -153,11 +153,11 @@ typedef struct lhash_st LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c); void lh_free(LHASH *lh); -void *lh_insert(LHASH *lh, void *data); -void *lh_delete(LHASH *lh, void *data); -void *lh_retrieve(LHASH *lh, void *data); +void *lh_insert(LHASH *lh, const void *data); +void *lh_delete(LHASH *lh, const void *data); +void *lh_retrieve(LHASH *lh, const void *data); void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); -void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, const void *arg); unsigned long lh_strhash(const char *c); unsigned long lh_num_items(const LHASH *lh); |