Index: ossp-pkg/act/act_hash_lh.c RCS File: /v/ossp/cvs/ossp-pkg/act/act_hash_lh.c,v rcsdiff -q -kk '-r1.4' '-r1.5' -u '/v/ossp/cvs/ossp-pkg/act/act_hash_lh.c,v' 2>/dev/null --- act_hash_lh.c 2000/08/19 10:25:50 1.4 +++ act_hash_lh.c 2000/08/19 10:37:17 1.5 @@ -39,9 +39,9 @@ /* fixed size (number of pointers) of the directory and of each segment */ #define INITDIRSIZE 256 /* can be an arbitrary value */ -#define SEGMENTSIZE 512 /* = 2^9, must be a power of 2 */ +#define SEGMENTSIZE 512 /* = 2^9, must be a power of 2 for below fast arithmetic */ -/* calculate index in directory and segments from virtual array index */ +/* calculate index in directory and segment from virtual array index */ #define DIRINDEX(addr) ((addr) >> 9) /* == ((addr) / SEGMENTSIZE) */ #define SEGINDEX(addr) ((addr) & (512-1)) /* == ((addr) % SEGMENTSIZE) */ @@ -82,7 +82,9 @@ }; /* create the hash table structure */ -static act_hash_lh_t *act_hash_lh_new(act_ctx_t *ctx) +static act_hash_lh_t * +act_hash_lh_new( + act_ctx_t *ctx) { act_hash_lh_t *h; @@ -94,14 +96,14 @@ /* allocate and clear hash table directory */ h->h_dirsize = INITDIRSIZE; if ((h->h_dir = (segment_t **)act_mem_alloc_ctx(ctx, h->h_dirsize * sizeof(segment_t *))) == NULL) { - errno_safe( act_mem_free_ctx(ctx, h) ); + errno_safe(act_mem_free_ctx(ctx, h)); return NULL; } act_mem_set(h->h_dir, 0, h->h_dirsize * sizeof(segment_t *)); /* allocate and clear first segment of hash table array */ if ((h->h_dir[0] = (segment_t *)act_mem_alloc_ctx(ctx, sizeof(segment_t))) == NULL) { - errno_safe( act_mem_free_ctx(ctx, h->h_dir); act_mem_free_ctx(ctx, h) ); + errno_safe(act_mem_free_ctx(ctx, h->h_dir); act_mem_free_ctx(ctx, h)); return NULL; } act_mem_set(h->h_dir[0], 0, sizeof(segment_t)); @@ -119,7 +121,10 @@ } /* expand the hash table */ -static void act_hash_lh_expand(act_ctx_t *ctx, act_hash_lh_t *h) +static void +act_hash_lh_expand( + act_ctx_t *ctx, + act_hash_lh_t *h) { unsigned int pmax0; unsigned int newaddr; @@ -180,7 +185,10 @@ } /* shrink hash table */ -static void act_hash_lh_shrink(act_ctx_t *ctx, act_hash_lh_t *h) +static void +act_hash_lh_shrink( + act_ctx_t *ctx, + act_hash_lh_t *h) { segment_t *lastseg; element_t **pel; @@ -230,8 +238,13 @@ } /* insert element into hash table */ -static int act_hash_lh_insert(act_ctx_t *ctx, act_hash_lh_t *h, void *keyptr, int keylen, - void *datptr, int datlen, int override) +static int +act_hash_lh_insert( + act_ctx_t *ctx, + act_hash_lh_t *h, + void *keyptr, int keylen, + void *datptr, int datlen, + int override) { unsigned int hash, addr; element_t *el, **pel; @@ -305,8 +318,12 @@ } /* lookup an element in hash table */ -static int act_hash_lh_lookup(act_ctx_t *ctx, act_hash_lh_t *h, - void *keyptr, int keylen, void **datptr, int *datlen) +static int +act_hash_lh_lookup( + act_ctx_t *ctx, + act_hash_lh_t *h, + void *keyptr, int keylen, + void **datptr, int *datlen) { unsigned int hash, addr; element_t *el, **pel; @@ -341,7 +358,11 @@ } /* delete an element in hash table */ -static int act_hash_lh_delete(act_ctx_t *ctx, act_hash_lh_t *h, void *keyptr, int keylen) +static int +act_hash_lh_delete( + act_ctx_t *ctx, + act_hash_lh_t *h, + void *keyptr, int keylen) { unsigned int hash, addr; element_t *el, *lel, **pel; @@ -389,7 +410,11 @@ } /* calculate total size of hash table */ -static int act_hash_lh_size(act_ctx_t *ctx, act_hash_lh_t *h, long *pbytes, long *pelements) +static int +act_hash_lh_size( + act_ctx_t *ctx, + act_hash_lh_t *h, + long *pbytes, long *pelements) { long bytes, elements; int i, j; @@ -437,7 +462,10 @@ } /* destroy the whole hash table */ -static int act_hash_lh_free(act_ctx_t *ctx, act_hash_lh_t *h) +static int +act_hash_lh_free( + act_ctx_t *ctx, + act_hash_lh_t *h) { element_t *el, **pel; unsigned int i, j;