Have llist_pop(0) return NULL the same way dlist_pop() does.
This commit is contained in:
parent
34a025cc0e
commit
7dc743d21f
11
lib/llist.c
11
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
|
||||
|
Loading…
Reference in New Issue
Block a user