Util: Enumerating a Table should list the key, too
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Dec 2014 00:41:03 -0800
2 files changed,
3 insertions(+),
3 deletions(-)
M
src/util/table.c
→
src/util/table.c
@@ -144,13 +144,13 @@ list->list = calloc(LIST_INITIAL_SIZE, sizeof(struct TableTuple));
} } -void TableEnumerate(const struct Table* table, void (handler(void* value, void* user)), void* user) { +void TableEnumerate(const struct Table* table, void (handler(uint32_t key, void* value, void* user)), void* user) { size_t i; for (i = 0; i < table->tableSize; ++i) { const struct TableList* list = &table->table[i]; size_t j; for (j = 0; j < list->nEntries; ++j) { - handler(list->list[j].value, user); + handler(list->list[j].key, list->list[j].value, user); } } }
M
src/util/table.h
→
src/util/table.h
@@ -25,7 +25,7 @@
void TableRemove(struct Table*, uint32_t key); void TableClear(struct Table*); -void TableEnumerate(const struct Table*, void (handler(void* value, void* user)), void* user); +void TableEnumerate(const struct Table*, void (handler(uint32_t key, void* value, void* user)), void* user); static inline void HashTableInit(struct Table* table, size_t initialSize, void (deinitializer(void*))) { TableInit(table, initialSize, deinitializer);