typedef enum { FIND, ENTER } ACTION;
typedef enum { preorder, postorder, endorder, leaf } VISIT;
-typedef struct {
+typedef struct entry {
char *key;
void *data;
} ENTRY;
#define MINSIZE 8
#define MAXSIZE ((size_t)-1/2 + 1)
-struct entry {
+struct elem {
ENTRY item;
size_t hash;
};
static size_t mask;
static size_t used;
-static struct entry *tab;
+static struct elem *tab;
static size_t keyhash(char *k)
{
{
size_t newsize;
size_t i, j;
- struct entry *e, *newe;
- struct entry *oldtab = tab;
- struct entry *oldend = tab + mask + 1;
+ struct elem *e, *newe;
+ struct elem *oldtab = tab;
+ struct elem *oldend = tab + mask + 1;
if (nel > MAXSIZE)
nel = MAXSIZE;
used = 0;
}
-static struct entry *lookup(char *key, size_t hash)
+static struct elem *lookup(char *key, size_t hash)
{
size_t i, j;
- struct entry *e;
+ struct elem *e;
for (i=hash,j=1; ; i+=j++) {
e = tab + (i & mask);
ENTRY *hsearch(ENTRY item, ACTION action)
{
size_t hash = keyhash(item.key);
- struct entry *e = lookup(item.key, hash);
+ struct elem *e = lookup(item.key, hash);
if (e->item.key)
return &e->item;