aboutsummaryrefslogtreecommitdiff
path: root/lib/llist.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-07-15 17:22:04 -0500
committerRob Landley <rob@landley.net>2012-07-15 17:22:04 -0500
commit9e2b6db36ab6486172fccd0e1786532826d58c53 (patch)
tree8027567bf76e073ad13594d634e0268de6f83e05 /lib/llist.c
parent2037b8396427ab82edd1912357e9177a2800b01a (diff)
downloadtoybox-9e2b6db36ab6486172fccd0e1786532826d58c53.tar.gz
Genericize llist code a bit: rename llist_free() to llist_traverse(), and no longer accept NULL as a synonym for free.
Diffstat (limited to 'lib/llist.c')
-rw-r--r--lib/llist.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/llist.c b/lib/llist.c
index 8588721b..4799db1c 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -6,15 +6,12 @@
#include "toys.h"
-// Free all the elements of a linked list
-// if freeit!=NULL call freeit() on each element before freeing it.
-
-void llist_free(void *list, void (*freeit)(void *data))
+// Call a function (such as free()) on each element of a linked list.
+void llist_traverse(void *list, void (*using)(void *data))
{
while (list) {
void *pop = llist_pop(&list);
- if (freeit) freeit(pop);
- else free(pop);
+ using(pop);
// End doubly linked list too.
if (list==pop) break;