summaryrefslogtreecommitdiffstats
path: root/libidu/hash.c
diff options
context:
space:
mode:
authorGreg McGary <greg@mcgary.org>1999-03-28 21:33:32 +0000
committerGreg McGary <greg@mcgary.org>1999-03-28 21:33:32 +0000
commit7833458af45e21e07bec538ec3fbd87a5603ca50 (patch)
treeba3585ada5ed1b1e4c57033acf5aede14f981e7f /libidu/hash.c
parentd4756b4ccc7f22845c0bbb73e6717ea7ed5c4a00 (diff)
downloadidutils-7833458af45e21e07bec538ec3fbd87a5603ca50.tar.gz
idutils-7833458af45e21e07bec538ec3fbd87a5603ca50.tar.bz2
idutils-7833458af45e21e07bec538ec3fbd87a5603ca50.zip
* libidu/hash.c (hash_insert): hash_insert_at no longer
returns old contents, but rather the new slot address. (hash_insert_at): Return slot address of inserted item. * libidu/walker.c (get_member_file): return member. (get_link_from_dirent, get_link_from_string): Conform to new hash_insert_at API, where return value is slot address of newly inserted item.
Diffstat (limited to 'libidu/hash.c')
-rw-r--r--libidu/hash.c12
1 files changed, 9 insertions, 3 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 *