From aff13c6581a8ef62df02bdea67814de34cc74083 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 5 Apr 1994 20:01:34 +0000 Subject: Formerly hash.c.~3~ --- proc/hash.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'proc') diff --git a/proc/hash.c b/proc/hash.c index 4eda40b8..52d7620d 100644 --- a/proc/hash.c +++ b/proc/hash.c @@ -57,18 +57,21 @@ addhash (struct htable *ht, int oldsize; int i; - for (h = HASH (id, ht); - (ht->tab[h] != 0 && ht->tab[h] != HASH_DEL && h != firsth); - firsth = (firsth == -1) ? h : firsth, h = REHASH (id, ht, h)) - ; - - if (ht->tab[h] == 0 - || ht->tab[h] == HASH_DEL) + if (ht->size) { - ht->tab[h] = item; - ht->ids[h] = id; - *locp = &ht->tab[h]; - return; + for (h = HASH (id, ht); + (ht->tab[h] != 0 && ht->tab[h] != HASH_DEL && h != firsth); + firsth = (firsth == -1) ? h : firsth, h = REHASH (id, ht, h)) + ; + + if (ht->tab[h] == 0 + || ht->tab[h] == HASH_DEL) + { + ht->tab[h] = item; + ht->ids[h] = id; + *locp = &ht->tab[h]; + return; + } } /* We have to rehash this again? */ @@ -103,6 +106,9 @@ findhash (struct htable *ht, int h, firsth = -1; void *ret; + if (ht->size == 0) + return 0; + for (h = HASH (id, ht); (ht->tab[h] != 0 && ht->ids[h] != id && h != firsth); firsth = (firsth == -1) ? h : firsth, h = REHASH (id, ht, h)) -- cgit v1.2.3