From 5030a225fd7ca4ca178794f47c2b0f3d482e2586 Mon Sep 17 00:00:00 2001 From: adamhutchings Date: Wed, 26 Jun 2024 10:09:26 -0400 Subject: [PATCH] Add literate function because I can read --- src/util/list.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/list.c b/src/util/list.c index c49cd87..c9c66d8 100644 --- a/src/util/list.c +++ b/src/util/list.c @@ -123,3 +123,15 @@ int ladd_element(List* l, void* element) { } return 0; } + +int literate(List* l, int (*fn)(void*)) { + ListBlock* lb = l->head; + int acc = 0; + while (lb != NULL) { + for (int i = 0; i < lb->full; ++i) { + acc += fn(lb->array[i]); + } + lb = lb->next; + } + return acc; +}