summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--proc/hash.c28
1 files changed, 17 insertions, 11 deletions
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))