diff options
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/hash-table.h | 11 | ||||
-rw-r--r-- | src/libmdsserver/linked-list.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/libmdsserver/hash-table.h b/src/libmdsserver/hash-table.h index edf8d3a..2f4d03b 100644 --- a/src/libmdsserver/hash-table.h +++ b/src/libmdsserver/hash-table.h @@ -220,6 +220,17 @@ size_t hash_table_remove(hash_table_t* restrict this, size_t key); void hash_table_clear(hash_table_t* restrict this); /** + * Wrapper for `for` keyword that iterates over entry element in a hash table + * + * @param table:hash_table_t The hans table + * @param i:size_t The variable to store the buckey index in at each iteration + * @param entry:hash_entry_t* The variable to store the entry in at each iteration + */ +#define foreach_hash_table_entry(table, i, entry) \ + for (i = 0; i < (table).capacity; i++) \ + for (entry = (table).buckets[i]; entry != NULL; entry = entry->next) + +/** * Calculate the buffer size need to marshal a hash table * * @param this The hash table diff --git a/src/libmdsserver/linked-list.h b/src/libmdsserver/linked-list.h index e2ec884..6ed7076 100644 --- a/src/libmdsserver/linked-list.h +++ b/src/libmdsserver/linked-list.h @@ -274,7 +274,7 @@ int linked_list_unmarshal(linked_list_t* restrict this, char* restrict data); * @param node:ssize_t The variable to store the node in at each iteration */ #define foreach_linked_list_node(list, node) \ - for (node = list.edge; node = list.next[node], node != list.edge;) + for (node = (list).edge; node = (list).next[node], node != (list).edge;) /** |