From 2aa778552f52001ab86f87151e4f352ebebe47dd Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 17 Jul 2011 09:51:48 +0000 Subject: [PATCH] nghash cleanup, struct forward declarations --- src/include/hash.h | 15 ++++++++++----- src/misc/hash.c | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/include/hash.h b/src/include/hash.h index 87978016e..f546fad07 100644 --- a/src/include/hash.h +++ b/src/include/hash.h @@ -31,14 +31,19 @@ typedef struct ngtable_rec { struct ngtable_rec *thread_prev ; /* thread thru entire table */ } NGTABLEBOX, *NGTABLEPTR ; -typedef struct nghashbox { +struct nghashbox; + +typedef unsigned int (*nghash_func)(struct nghashbox *, void *) ; +typedef int (*COMPARE_FUNC)(void *,void *) ; + +struct nghashbox { NGTABLEPTR *hash_table ; NGTABLEPTR thread ; /* thread of hash table */ NGTABLEPTR last_entry ; /* last entry into hash table */ NGTABLEPTR enumeratePtr ; /* used to enumerate hash table */ NGTABLEPTR searchPtr ; /* used for find again mechanism */ void *compare_func ; /* the comparison function */ - void *hash_func ; /* the hash function */ + nghash_func hash_func ; /* the hash function */ double growth_factor ; /* how much to grow table by */ int size ; /* the size of the table */ int max_density ; /* maximum number of entries before growth */ @@ -49,7 +54,9 @@ typedef struct nghashbox { unsigned int power_of_two : 8 ; /* build table as a power of two */ unsigned int call_from_free : 8 ;/* true if in a free calling sequence */ unsigned int unique : 16 ; /* true if only one unique item in col. list */ -} NGHASHBOX, *NGHASHPTR ; +}; + +typedef struct nghashbox NGHASHBOX, *NGHASHPTR; /* ----------------------------------------------------------------- * This enumerated type is used to control the base hash function types @@ -69,8 +76,6 @@ typedef enum { NGHASH_UNIQUE_TWO = NGHASH_UNIQUE | NGHASH_POWER_OF_TWO } NGHASHFLAGS_T ; -typedef unsigned int (*nghash_func)(NGHASHPTR,void *) ; - typedef struct nghash_iter_rec { struct ngtable_rec *position ; diff --git a/src/misc/hash.c b/src/misc/hash.c index 1b65d41ec..9de59f0ce 100644 --- a/src/misc/hash.c +++ b/src/misc/hash.c @@ -32,7 +32,6 @@ REVISIONS: /* ********************** TYPE DEFINITIONS ************************* */ #define PRIMECOUNT 200 #define MINPRIMESIZE 7 -typedef int (*COMPARE_FUNC)(void *,void *) ; /* ********************** STATIC DEFINITIONS ************************* */ static NGTABLEPTR _nghash_find_item(NGHASHPTR hhtable,void *user_key,void *data) ;