Have llist_pop(0) return NULL the same way dlist_pop() does.

This commit is contained in:
Rob Landley 2021-12-28 16:17:50 -06:00
parent 34a025cc0e
commit 7dc743d21f

View File

@ -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