all repos — mgba @ 1b6389164c6b083ac1c0f25c34c439d763a1c82b

mGBA Game Boy Advance Emulator

Util: Enumerating a Table should list the key, too
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Dec 2014 00:41:03 -0800
commit

1b6389164c6b083ac1c0f25c34c439d763a1c82b

parent

2b6462c3a8ea2742374adf65d36aa906df6b51e8

2 files changed, 3 insertions(+), 3 deletions(-)

jump to
M src/util/table.csrc/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.hsrc/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);