2 * llist.c - Linked list functions
4 * Linked list structures have a next pointer as their first element.
9 // Free all the elements of a linked list
10 // if freeit!=NULL call freeit() on each element before freeing it.
12 void llist_free(void *list, void (*freeit)(void *data))
15 void *pop = llist_pop(&list);
16 if (freeit) freeit(pop);
20 // Return the first item from the list, advancing the list (which must be called
22 void *llist_pop(void *list)
24 // I'd use a void ** for the argument, and even accept the typecast in all
25 // callers as documentation you need the &, except the stupid compiler
26 // would then scream about type-punned pointers. Screw it.
27 void **llist = (void **)list;
28 void **next = (void **)*llist;