X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fhash.c;h=fa35ba6d167ac330ad0784fac68ad6383a279ecb;hb=78d3e1bf81e401020937b98d17bdfe2107623029;hp=fd92045bc333e3bde2e061ddecc765c89b57ba38;hpb=fe14fcc35f78a371a174a1d14256c2f35ae4262b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/hash.c b/x2p/hash.c index fd92045..fa35ba6 100644 --- a/x2p/hash.c +++ b/x2p/hash.c @@ -1,26 +1,20 @@ -/* $Header: hash.c,v 4.0 91/03/20 01:57:49 lwall Locked $ +/* $RCSfile: hash.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:20 $ * - * Copyright (c) 1989, Larry Wall + * Copyright (c) 1991-2001, Larry Wall * - * You may distribute under the terms of the GNU General Public License - * as specified in the README file that comes with the perl 3.0 kit. + * You may distribute under the terms of either the GNU General Public + * License or the Artistic License, as specified in the README file. * * $Log: hash.c,v $ - * Revision 4.0 91/03/20 01:57:49 lwall - * 4.0 baseline. - * */ #include #include "EXTERN.h" -#include "handy.h" -#include "util.h" #include "a2p.h" +#include "util.h" STR * -hfetch(tb,key) -register HASH *tb; -char *key; +hfetch(register HASH *tb, char *key) { register char *s; register int i; @@ -46,10 +40,7 @@ char *key; } bool -hstore(tb,key,val) -register HASH *tb; -char *key; -STR *val; +hstore(register HASH *tb, char *key, STR *val) { register char *s; register int i; @@ -74,7 +65,7 @@ STR *val; if (strNE(entry->hent_key,key)) /* is this it? */ continue; /*NOSTRICT*/ - safefree((char*)entry->hent_val); + safefree(entry->hent_val); entry->hent_val = val; return TRUE; } @@ -98,9 +89,7 @@ STR *val; #ifdef NOTUSED bool -hdelete(tb,key) -register HASH *tb; -char *key; +hdelete(register HASH *tb, char *key) { register char *s; register int i; @@ -136,8 +125,8 @@ char *key; } #endif -hsplit(tb) -HASH *tb; +void +hsplit(HASH *tb) { int oldsize = tb->tbl_max + 1; register int newsize = oldsize * 2; @@ -148,7 +137,7 @@ HASH *tb; register HENT **oentry; a = (HENT**) saferealloc((char*)tb->tbl_array, newsize * sizeof(HENT*)); - bzero((char*)&a[oldsize], oldsize * sizeof(HENT*)); /* zero second half */ + memset(&a[oldsize], 0, oldsize * sizeof(HENT*)); /* zero second half */ tb->tbl_max = --newsize; tb->tbl_array = a; @@ -174,7 +163,7 @@ HASH *tb; } HASH * -hnew() +hnew(void) { register HASH *tb = (HASH*)safemalloc(sizeof(HASH)); @@ -182,13 +171,12 @@ hnew() tb->tbl_fill = 0; tb->tbl_max = 7; hiterinit(tb); /* so each() will start off right */ - bzero((char*)tb->tbl_array, 8 * sizeof(HENT*)); + memset(tb->tbl_array, 0, 8 * sizeof(HENT*)); return tb; } #ifdef NOTUSED -hshow(tb) -register HASH *tb; +hshow(register HASH *tb) { fprintf(stderr,"%5d %4d (%2d%%)\n", tb->tbl_max+1, @@ -197,8 +185,8 @@ register HASH *tb; } #endif -hiterinit(tb) -register HASH *tb; +int +hiterinit(register HASH *tb) { tb->tbl_riter = -1; tb->tbl_eiter = Null(HENT*); @@ -206,8 +194,7 @@ register HASH *tb; } HENT * -hiternext(tb) -register HASH *tb; +hiternext(register HASH *tb) { register HENT *entry; @@ -230,15 +217,13 @@ register HASH *tb; } char * -hiterkey(entry) -register HENT *entry; +hiterkey(register HENT *entry) { return entry->hent_key; } STR * -hiterval(entry) -register HENT *entry; +hiterval(register HENT *entry) { return entry->hent_val; }