diff options
author | Geoff Thorpe <geoff@openssl.org> | 2000-12-01 20:31:52 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2000-12-01 20:31:52 +0000 |
commit | 385d81380cb8aa062b9d7e2c678419623c7db484 (patch) | |
tree | f866963b5b03410694d03a37d20695327a72a460 /crypto/lhash/lhash.h | |
parent | 862e973b50e56d9510cfebc220cf410d3d5e99bc (diff) |
First step in tidying up the LHASH code. The callback prototypes (and
casts) used in the lhash code are about as horrible and evil as they can
be. For starters, the callback prototypes contain empty parameter lists.
Yuck.
This first change defines clearer prototypes - including "typedef"'d
function pointer types to use as "hash" and "compare" callbacks, as well as
the callbacks passed to the lh_doall and lh_doall_arg iteration functions.
Now at least more explicit (and clear) casting is required in all of the
dependant code - and that should be included in this commit.
The next step will be to hunt down and obliterate some of the function
pointer casting being used when it's not necessary - a particularly evil
variant exists in the implementation of lh_doall.
Diffstat (limited to 'crypto/lhash/lhash.h')
-rw-r--r-- | crypto/lhash/lhash.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/crypto/lhash/lhash.h b/crypto/lhash/lhash.h index 28e8f1ef0a..0c1e2d2338 100644 --- a/crypto/lhash/lhash.h +++ b/crypto/lhash/lhash.h @@ -84,11 +84,16 @@ typedef struct lhash_node_st #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 struct lhash_st { LHASH_NODE **b; - int (*comp)(); - unsigned long (*hash)(); + LHASH_COMP_FN_TYPE comp; + LHASH_HASH_FN_TYPE hash; unsigned int num_nodes; unsigned int num_alloc_nodes; unsigned int p; @@ -120,13 +125,13 @@ typedef struct lhash_st * in lh_insert(). */ #define lh_error(lh) ((lh)->error) -LHASH *lh_new(unsigned long (*h)(/* void *a */), int (*c)(/* void *a,void *b */)); +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_doall(LHASH *lh, void (*func)(/*void *b*/)); -void lh_doall_arg(LHASH *lh, void (*func)(/*void *a,void *b*/),void *arg); +void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func); +void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg); unsigned long lh_strhash(const char *c); unsigned long lh_num_items(const LHASH *lh); |