--- src/lib/libc/db/hash/hash.c 2005/01/31 22:29:09 1.5 +++ src/lib/libc/db/hash/hash.c 2005/04/25 08:33:25 1.6 @@ -59,23 +59,23 @@ #include "page.h" #include "extern.h" -static int alloc_segs (HTAB *, int); -static int flush_meta (HTAB *); -static int hash_access (HTAB *, ACTION, DBT *, DBT *); -static int hash_close (DB *); -static int hash_delete (const DB *, const DBT *, u_int32_t); -static int hash_fd (const DB *); -static int hash_get (const DB *, const DBT *, DBT *, u_int32_t); -static int hash_put (const DB *, DBT *, const DBT *, u_int32_t); -static void *hash_realloc (SEGMENT **, int, int); -static int hash_seq (const DB *, DBT *, DBT *, u_int32_t); -static int hash_sync (const DB *, u_int32_t); -static int hdestroy (HTAB *); -static HTAB *init_hash (HTAB *, const char *, HASHINFO *); -static int init_htab (HTAB *, int); +static int alloc_segs(HTAB *, int); +static int flush_meta(HTAB *); +static int hash_access(HTAB *, ACTION, DBT *, DBT *); +static int hash_close(DB *); +static int hash_delete(const DB *, const DBT *, u_int32_t); +static int hash_fd(const DB *); +static int hash_get(const DB *, const DBT *, DBT *, u_int32_t); +static int hash_put(const DB *, DBT *, const DBT *, u_int32_t); +static void *hash_realloc(SEGMENT **, int, int); +static int hash_seq(const DB *, DBT *, DBT *, u_int32_t); +static int hash_sync(const DB *, u_int32_t); +static int hdestroy(HTAB *); +static HTAB *init_hash(HTAB *, const char *, HASHINFO *); +static int init_htab(HTAB *, int); #if BYTE_ORDER == LITTLE_ENDIAN -static void swap_header (HTAB *); -static void swap_header_copy (HASHHDR *, HASHHDR *); +static void swap_header(HTAB *); +static void swap_header_copy(HASHHDR *, HASHHDR *); #endif /* Fast arithmetic, relying on powers of 2, */ @@ -96,10 +96,8 @@ int hash_accesses, hash_collisions, hash /* OPEN/CLOSE */ extern DB * -__hash_open(file, flags, mode, info, dflags) - const char *file; - int flags, mode, dflags; - const HASHINFO *info; /* Special directives for create */ +__hash_open(const char *file, int flags, int mode, const HASHINFO * info, + int dflags) { HTAB *hashp; struct stat statbuf; @@ -252,8 +250,7 @@ error0: } static int -hash_close(dbp) - DB *dbp; +hash_close(DB *dbp) { HTAB *hashp; int retval; @@ -268,8 +265,7 @@ hash_close(dbp) } static int -hash_fd(dbp) - const DB *dbp; +hash_fd(const DB *dbp) { HTAB *hashp; @@ -286,10 +282,7 @@ hash_fd(dbp) /************************** LOCAL CREATION ROUTINES **********************/ static HTAB * -init_hash(hashp, file, info) - HTAB *hashp; - const char *file; - HASHINFO *info; +init_hash(HTAB *hashp, const char *file, HASHINFO *info) { struct stat statbuf; int nelem; @@ -353,9 +346,7 @@ init_hash(hashp, file, info) * Returns 0 on No Error */ static int -init_htab(hashp, nelem) - HTAB *hashp; - int nelem; +init_htab(HTAB *hashp, int nelem) { int nbuckets, nsegs; int l2; @@ -399,8 +390,7 @@ init_htab(hashp, nelem) * structure, freeing all allocated space. */ static int -hdestroy(hashp) - HTAB *hashp; +hdestroy(HTAB *hashp) { int i, save_errno; @@ -459,9 +449,7 @@ hdestroy(hashp) * -1 ERROR */ static int -hash_sync(dbp, flags) - const DB *dbp; - u_int32_t flags; +hash_sync(const DB *dbp, u_int32_t flags) { HTAB *hashp; @@ -488,8 +476,7 @@ hash_sync(dbp, flags) * -1 indicates that errno should be set */ static int -flush_meta(hashp) - HTAB *hashp; +flush_meta(HTAB *hashp) { HASHHDR *whdrp; #if BYTE_ORDER == LITTLE_ENDIAN @@ -536,11 +523,7 @@ flush_meta(hashp) * -1 to indicate an internal ERROR (i.e. out of memory, etc) */ static int -hash_get(dbp, key, data, flag) - const DB *dbp; - const DBT *key; - DBT *data; - u_int32_t flag; +hash_get(const DB *dbp, const DBT *key, DBT *data, u_int32_t flag) { HTAB *hashp; @@ -554,11 +537,7 @@ hash_get(dbp, key, data, flag) } static int -hash_put(dbp, key, data, flag) - const DB *dbp; - DBT *key; - const DBT *data; - u_int32_t flag; +hash_put(const DB *dbp, DBT *key, const DBT *data, u_int32_t flag) { HTAB *hashp; @@ -576,10 +555,7 @@ hash_put(dbp, key, data, flag) } static int -hash_delete(dbp, key, flag) - const DB *dbp; - const DBT *key; - u_int32_t flag; /* Ignored */ +hash_delete(const DB *dbp, const DBT *key, u_int32_t flag) { HTAB *hashp; @@ -599,10 +575,7 @@ hash_delete(dbp, key, flag) * Assume that hashp has been set in wrapper routine. */ static int -hash_access(hashp, action, key, val) - HTAB *hashp; - ACTION action; - DBT *key, *val; +hash_access(HTAB *hashp, ACTION action, DBT *key, DBT *val) { BUFHEAD *rbufp; BUFHEAD *bufp, *save_bufp; @@ -728,10 +701,7 @@ found: } static int -hash_seq(dbp, key, data, flag) - const DB *dbp; - DBT *key, *data; - u_int32_t flag; +hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t flag) { u_int32_t bucket; BUFHEAD *bufp; @@ -818,8 +788,7 @@ hash_seq(dbp, key, data, flag) * -1 ==> Error */ extern int -__expand_table(hashp) - HTAB *hashp; +__expand_table(HTAB *hashp) { u_int32_t old_bucket, new_bucket; int dirsize, new_segnum, spare_ndx; @@ -873,9 +842,7 @@ __expand_table(hashp) * fails, then this routine can go away. */ static void * -hash_realloc(p_ptr, oldsize, newsize) - SEGMENT **p_ptr; - int oldsize, newsize; +hash_realloc(SEGMENT **p_ptr, int oldsize, int newsize) { void *p; @@ -889,10 +856,7 @@ hash_realloc(p_ptr, oldsize, newsize) } extern u_int32_t -__call_hash(hashp, k, len) - HTAB *hashp; - char *k; - int len; +__call_hash(HTAB *hashp, char *k, int len) { int n, bucket; @@ -909,9 +873,7 @@ __call_hash(hashp, k, len) * Returns 0 on success */ static int -alloc_segs(hashp, nsegs) - HTAB *hashp; - int nsegs; +alloc_segs(HTAB *hashp, int nsegs) { int i; SEGMENT store; @@ -943,8 +905,7 @@ alloc_segs(hashp, nsegs) * Hashp->hdr needs to be byteswapped. */ static void -swap_header_copy(srcp, destp) - HASHHDR *srcp, *destp; +swap_header_copy(HASHHDR *srcp, HASHHDR *destp) { int i; @@ -972,8 +933,7 @@ swap_header_copy(srcp, destp) } static void -swap_header(hashp) - HTAB *hashp; +swap_header(HTAB *hashp) { HASHHDR *hdrp; int i;