mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Commit hash table bugfix.
Published in <sxs8zqd9x1g.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
6663d70a0a
commit
d6a57bc2a6
@ -1,3 +1,7 @@
|
|||||||
|
2000-11-21 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* hash.c (hash_table_put): Don't overwrite deleted mappings.
|
||||||
|
|
||||||
2000-11-21 Hrvoje Niksic <hniksic@arsdigita.com>
|
2000-11-21 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* hash.c (find_mapping): New function.
|
* hash.c (find_mapping): New function.
|
||||||
|
20
src/hash.c
20
src/hash.c
@ -329,8 +329,8 @@ grow_hash_table (struct hash_table *ht)
|
|||||||
void
|
void
|
||||||
hash_table_put (struct hash_table *ht, const void *key, void *value)
|
hash_table_put (struct hash_table *ht, const void *key, void *value)
|
||||||
{
|
{
|
||||||
/* Cannot use find_mapping here because we treat deleted entries
|
/* Cannot use find_mapping here because we're actually looking for
|
||||||
specially. */
|
an *empty* entry. */
|
||||||
|
|
||||||
struct mapping *mappings = ht->mappings;
|
struct mapping *mappings = ht->mappings;
|
||||||
int size = ht->size;
|
int size = ht->size;
|
||||||
@ -349,24 +349,18 @@ hash_table_put (struct hash_table *ht, const void *key, void *value)
|
|||||||
mp->value = value;
|
mp->value = value;
|
||||||
break;
|
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
|
if (++location == size)
|
||||||
increased, but ht->fullness remains unchanged. */
|
location = 0;
|
||||||
++ht->count;
|
|
||||||
goto just_insert;
|
|
||||||
}
|
}
|
||||||
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
|
/* We're replacing an existing entry, so ht->count and
|
||||||
ht->fullness remain unchanged. */
|
ht->fullness remain unchanged. */
|
||||||
goto just_insert;
|
goto just_insert;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (++location == size)
|
|
||||||
location = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (ht->fullness * 4 > ht->size * 3)
|
if (ht->fullness * 4 > ht->size * 3)
|
||||||
/* When fullness exceeds 75% of size, regrow the table. */
|
/* When fullness exceeds 75% of size, regrow the table. */
|
||||||
|
Loading…
Reference in New Issue
Block a user