Skip to content

Commit

Permalink
Add literate function because I can read
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhutchings committed Jun 26, 2024
1 parent ac4dbcc commit 5030a22
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/util/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 5030a22

Please sign in to comment.