From 6381197d09637de75bf81e7bc9c78b06f878088f Mon Sep 17 00:00:00 2001 From: Fabrice Date: Sun, 22 Mar 2026 21:55:00 +0100 Subject: iterator helper --- cheesemap.h | 3 +++ cm-demo.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cheesemap.h b/cheesemap.h index 436bfe1..50fa7bf 100644 --- a/cheesemap.h +++ b/cheesemap.h @@ -176,6 +176,9 @@ void cm_iter_init(struct cheesemap_iter* iter, const struct cheesemap* map); bool cm_iter_next(struct cheesemap_iter* iter, const struct cheesemap* map, uint8_t** out_key, uint8_t** out_value); +#define cm_iter_next_(iter, map, out_key, out_val) \ + cm_iter_next(iter, map, (uint8_t**)(out_key), (uint8_t**)(out_val)) + #ifdef __cplusplus } #endif diff --git a/cm-demo.c b/cm-demo.c index 3d91843..7a5a3e2 100644 --- a/cm-demo.c +++ b/cm-demo.c @@ -46,7 +46,7 @@ int main(void) { cm_iter_init(&iter, &map); const char** word; int* count; - while (cm_iter_next(&iter, &map, (uint8_t**)&word, (uint8_t**)&count)) { + while (cm_iter_next_(&iter, &map, &word, &count)) { printf(" %s: %d\n", *word, *count); } -- cgit v1.2.3