summaryrefslogtreecommitdiffstats
path: root/libidu
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
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')
-rw-r--r--libidu/hash.c12
-rw-r--r--libidu/walker.c8
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;