From 34f7eaea19070f1a141769b94b6ab61c4d1649ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Mon, 29 Jul 2024 15:11:21 +0500 Subject: [PATCH] Make it possible to pass "clojures" into hashtable_forall --- hashtable.c | 4 ++-- hashtable.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hashtable.c b/hashtable.c index a4025be..244b453 100644 --- a/hashtable.c +++ b/hashtable.c @@ -106,9 +106,9 @@ bool hashtable_delete(hashtable* table, char* name) { return false; } -void hashtable_forall(hashtable* table, void (*callback)(char*, void*)) { +void hashtable_forall(hashtable* table, void (*callback)(char*, void*, void*), void* userdata) { size_t capacity = table->capacity; hashtable_item* items = table->items; for (size_t i = 0; i < capacity; i++) - callback(items[i].name, items[i].data); + callback(items[i].name, items[i].data, userdata); } diff --git a/hashtable.h b/hashtable.h index 967b735..b866665 100644 --- a/hashtable.h +++ b/hashtable.h @@ -33,4 +33,4 @@ void hashtable_set(hashtable* table, char* name, void* data); bool hashtable_delete(hashtable*, char*); -void hashtable_forall(hashtable*, void (*)(char*, void*)); +void hashtable_forall(hashtable*, void (*)(char*, void*, void*), void*);