diff options
author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-24 14:05:40 +0100 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-03-24 14:36:20 +0100 |
commit | 0ed6ef2567a8355013e2cd61a1a31df6be67ae01 (patch) | |
tree | 1967a00bfe73a11cafbee7a5e97173abd7699add /src/lib | |
parent | 2ee56ae4d3c90b77d77e9be8e5e00832256e50de (diff) | |
download | ouroboros-0ed6ef2567a8355013e2cd61a1a31df6be67ae01.tar.gz ouroboros-0ed6ef2567a8355013e2cd61a1a31df6be67ae01.zip |
ipcpd: normal: Fill in forwarding table
The routing now takes the results of the routing table to fill in the
forwarding table, by going through the neighbors and filling in the
right fd.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/hashtable.c | 18 | ||||
-rw-r--r-- | src/lib/tests/hashtable_test.c | 10 |
2 files changed, 14 insertions, 14 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) diff --git a/src/lib/tests/hashtable_test.c b/src/lib/tests/hashtable_test.c index a5b0e469..1160e34d 100644 --- a/src/lib/tests/hashtable_test.c +++ b/src/lib/tests/hashtable_test.c @@ -42,10 +42,7 @@ int hashtable_test(int argc, char ** argv) return -1; } - if (htable_destroy(table)) { - printf("Failed to destroy.\n"); - return -1; - } + htable_destroy(table); table = htable_create(HASHTABLE_SIZE, false); if (table == NULL) { @@ -124,10 +121,7 @@ int hashtable_test(int argc, char ** argv) return -1; } - if (htable_destroy(table)) { - printf("Failed to destroy.\n"); - return -1; - } + htable_destroy(table); return 0; } |