X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fhash.c;h=705d8d3f137f1d550c93d3b6815c7fa12b79712a;hb=d6a57bc2a632096c0625d50070645f359d79bc9c;hp=0749f57bdb58cf35549c310a9078438ba3a3c0df;hpb=6663d70a0a4a72b3e44a453ab0d6c8bfc7bf9167;p=wget diff --git a/src/hash.c b/src/hash.c index 0749f57b..705d8d3f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -329,8 +329,8 @@ grow_hash_table (struct hash_table *ht) void hash_table_put (struct hash_table *ht, const void *key, void *value) { - /* Cannot use find_mapping here because we treat deleted entries - specially. */ + /* Cannot use find_mapping here because we're actually looking for + an *empty* entry. */ struct mapping *mappings = ht->mappings; int size = ht->size; @@ -349,24 +349,18 @@ hash_table_put (struct hash_table *ht, const void *key, void *value) mp->value = value; break; } - else if (DELETED_ENTRY_P (mp_key)) + else if (DELETED_ENTRY_P (mp_key) + || !ht->test_function (key, mp_key)) { - /* We're replacing a deleteed entry, so ht->count gets - increased, but ht->fullness remains unchanged. */ - ++ht->count; - goto just_insert; + if (++location == size) + location = 0; } - else if (ht->test_function (key, mp_key)) + else /* equal to key and not deleted */ { /* We're replacing an existing entry, so ht->count and ht->fullness remain unchanged. */ goto just_insert; } - else - { - if (++location == size) - location = 0; - } } if (ht->fullness * 4 > ht->size * 3) /* When fullness exceeds 75% of size, regrow the table. */