/* $RCSfile: hash.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:20 $
*
- * Copyright (c) 1991, 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 either the GNU General Public
* License or the Artistic License, as specified in the README file.
#include <stdio.h>
#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;
}
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;
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;
}
#ifdef NOTUSED
bool
-hdelete(tb,key)
-register HASH *tb;
-char *key;
+hdelete(register HASH *tb, char *key)
{
register char *s;
register int i;
}
#endif
-hsplit(tb)
-HASH *tb;
+void
+hsplit(HASH *tb)
{
int oldsize = tb->tbl_max + 1;
register int newsize = oldsize * 2;
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;
}
HASH *
-hnew()
+hnew(void)
{
register HASH *tb = (HASH*)safemalloc(sizeof(HASH));
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,
}
#endif
-hiterinit(tb)
-register HASH *tb;
+int
+hiterinit(register HASH *tb)
{
tb->tbl_riter = -1;
tb->tbl_eiter = Null(HENT*);
}
HENT *
-hiternext(tb)
-register HASH *tb;
+hiternext(register HASH *tb)
{
register HENT *entry;
}
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;
}