diff options
-rw-r--r-- | libidu/hash.c | 12 | ||||
-rw-r--r-- | libidu/walker.c | 8 |
2 files changed, 14 insertions, 6 deletions
diff --git a/libidu/hash.c b/libidu/hash.c index 890fad4..dc764af 100644 --- a/libidu/hash.c +++ b/libidu/hash.c @@ -124,7 +124,9 @@ void * hash_insert (struct hash_table* ht, void *item) { void **slot = hash_find_slot (ht, item); - return hash_insert_at (ht, item, slot); + void *old_item = slot ? *slot : 0; + hash_insert_at (ht, item, slot); + return ((HASH_VACANT (old_item)) ? 0 : old_item); } void * @@ -140,8 +142,12 @@ hash_insert_at (struct hash_table* ht, void *item, void const *slot) } *(void const **) slot = item; if (ht->ht_empty_slots < ht->ht_size - ht->ht_capacity) - hash_rehash (ht); - return old_item; + { + hash_rehash (ht); + return (void *) hash_find_slot (ht, item); + } + else + return (void *) slot; } void * diff --git a/libidu/walker.c b/libidu/walker.c index d2c1940..80d1b59 100644 --- a/libidu/walker.c +++ b/libidu/walker.c @@ -388,7 +388,7 @@ get_member_file (struct file_link *flink) member = *slot; } member->mf_lang_args = args; - return *slot; + return member; } struct member_file * @@ -729,7 +729,8 @@ get_link_from_dirent (struct dirent *dirent, struct file_link *parent) new_link = make_link_from_dirent (dirent, parent); slot = (struct file_link **) hash_find_slot (&idh.idh_file_link_table, new_link); if (HASH_VACANT (*slot)) - hash_insert_at (&idh.idh_file_link_table, new_link, slot); + slot = (struct file_link **) hash_insert_at (&idh.idh_file_link_table, + new_link, slot); else obstack_free (&idh.idh_file_link_obstack, new_link); return *slot; @@ -744,7 +745,8 @@ get_link_from_string (char const *name, struct file_link *parent) new_link = make_link_from_string (name, parent); slot = (struct file_link **) hash_find_slot (&idh.idh_file_link_table, new_link); if (HASH_VACANT (*slot)) - hash_insert_at (&idh.idh_file_link_table, new_link, slot); + slot = (struct file_link **) hash_insert_at (&idh.idh_file_link_table, + new_link, slot); else obstack_free (&idh.idh_file_link_obstack, new_link); return *slot; |