summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1994-04-05 20:01:34 +0000
committerMichael I. Bushnell <mib@gnu.org>1994-04-05 20:01:34 +0000
commitaff13c6581a8ef62df02bdea67814de34cc74083 (patch)
treee00fae382b0551e1f328b885fbb2c491d2cfc406 /proc
parentba5b71d436a67be6a35d6c7a98ece82fb2d5bd4a (diff)
Formerly hash.c.~3~
Diffstat (limited to 'proc')
-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))