diff --git a/lib/llist.c b/lib/llist.c index e82cb954b..6ceb1ce7e 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -41,14 +41,13 @@ void llist_traverse(void *list, void (*using)(void *node)) // as &list) void *llist_pop(void *list) { - // I'd use a void ** for the argument, and even accept the typecast in all - // callers as documentation you need the &, except the stupid compiler - // would then scream about type-punned pointers. Screw it. - void **llist = (void **)list; - void **next = (void **)*llist; + void **llist = list, **next; + + if (!list || !*llist) return 0; + next = (void **)*llist; *llist = *next; - return (void *)next; + return next; } // Remove first item from &list and return it