summaryrefslogtreecommitdiff
path: root/src/lib/hashtable.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2017-03-24 13:36:48 +0000
committerdimitri staessens <[email protected]>2017-03-24 13:36:48 +0000
commit25d262cb383039b1d97a5b41ec477d6a40957398 (patch)
tree1967a00bfe73a11cafbee7a5e97173abd7699add /src/lib/hashtable.c
parente7f439e31aa8cd972b567da8c0421faa1ca09e59 (diff)
parent0ed6ef2567a8355013e2cd61a1a31df6be67ae01 (diff)
downloadouroboros-25d262cb383039b1d97a5b41ec477d6a40957398.tar.gz
ouroboros-25d262cb383039b1d97a5b41ec477d6a40957398.zip
Merged in sandervrijders/ouroboros/be-full-pff (pull request #421)
ipcpd: normal: Fill in forwarding table
Diffstat (limited to 'src/lib/hashtable.c')
-rw-r--r--src/lib/hashtable.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/hashtable.c b/src/lib/hashtable.c
index 0a534da7..77b56075 100644
--- a/src/lib/hashtable.c
+++ b/src/lib/hashtable.c
@@ -76,7 +76,17 @@ struct htable * htable_create(uint64_t buckets, bool hash_key)
return tmp;
}
-int htable_destroy(struct htable * table)
+void htable_destroy(struct htable * table)
+{
+ assert(table);
+ assert(table->buckets);
+
+ htable_flush(table);
+ free(table->buckets);
+ free(table);
+}
+
+void htable_flush(struct htable * table)
{
unsigned int i;
struct list_head * pos = NULL;
@@ -88,15 +98,11 @@ int htable_destroy(struct htable * table)
for (i = 0; i < table->buckets_size; i++) {
list_for_each_safe(pos, n, &(table->buckets[i])) {
entry = list_entry(pos, struct htable_entry, next);
+ list_del(&entry->next);
free(entry->val);
free(entry);
}
}
-
- free(table->buckets);
- free(table);
-
- return 0;
}
static uint64_t hash(uint64_t x)