X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fhash.c;h=07936f8c4e3a72d879a0748c4b2b54dd245deaa4;hb=a4d60858fc3c717ec83cbdceb029a69fc535e3f8;hp=a89b6511e43304fa9848ced72aebcdd02e42767d;hpb=a687059cbaf2c6fdccb5e0fae2aee80ec15625a8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/hash.c b/x2p/hash.c index a89b651..07936f8 100644 --- a/x2p/hash.c +++ b/x2p/hash.c @@ -1,26 +1,25 @@ -/* $Header: hash.c,v 3.0 89/10/18 15:34:50 lwall Locked $ +/* $RCSfile: hash.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:20 $ * - * Copyright (c) 1989, Larry Wall + * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002, + * by Larry Wall and others * - * 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 3.0 89/10/18 15:34:50 lwall - * 3.0 baseline - * */ #include #include "EXTERN.h" -#include "handy.h" -#include "util.h" #include "a2p.h" +#include "util.h" + +#ifdef NETWARE +char *savestr(char *str); +#endif STR * -hfetch(tb,key) -register HASH *tb; -char *key; +hfetch(register HASH *tb, char *key) { register char *s; register int i; @@ -46,10 +45,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; @@ -73,10 +69,12 @@ STR *val; continue; if (strNE(entry->hent_key,key)) /* is this it? */ continue; - safefree((char*)entry->hent_val); + /*NOSTRICT*/ + safefree(entry->hent_val); entry->hent_val = val; return TRUE; } + /*NOSTRICT*/ entry = (HENT*) safemalloc(sizeof(HENT)); entry->hent_key = savestr(key); @@ -96,9 +94,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; @@ -134,8 +130,8 @@ char *key; } #endif -hsplit(tb) -HASH *tb; +void +hsplit(HASH *tb) { int oldsize = tb->tbl_max + 1; register int newsize = oldsize * 2; @@ -146,7 +142,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; @@ -172,7 +168,7 @@ HASH *tb; } HASH * -hnew() +hnew(void) { register HASH *tb = (HASH*)safemalloc(sizeof(HASH)); @@ -180,13 +176,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, @@ -195,8 +190,8 @@ register HASH *tb; } #endif -hiterinit(tb) -register HASH *tb; +int +hiterinit(register HASH *tb) { tb->tbl_riter = -1; tb->tbl_eiter = Null(HENT*); @@ -204,8 +199,7 @@ register HASH *tb; } HENT * -hiternext(tb) -register HASH *tb; +hiternext(register HASH *tb) { register HENT *entry; @@ -228,15 +222,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; }