diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-04-01 18:09:48 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-04-01 18:09:48 -0400 |
commit | c4a4d397ccc124f50b851cfa52b9937ba7485b2b (patch) | |
tree | 0643ade6b2ccda7f0b9f270ad2c4a6b82cbf9994 /src/list.h | |
parent | ecbc4a7572cb67802b1cb99d8914c19f1fb4f2c4 (diff) | |
download | bfs-c4a4d397ccc124f50b851cfa52b9937ba7485b2b.tar.xz |
list: Fix SLIST_REMOVE() on the tail
Diffstat (limited to 'src/list.h')
-rw-r--r-- | src/list.h | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -234,21 +234,21 @@ * * @param list * The list to remove from. - * @param ptr + * @param cursor * A pointer to the item to remove, either &list->head or &prev->next. * @param link (optional) * If specified, use item->link.next rather than item->next. */ #define SLIST_REMOVE(list, ...) SLIST_REMOVE_(list, __VA_ARGS__, ) -#define SLIST_REMOVE_(list, ptr, ...) \ - LIST_BLOCK_(SLIST_REMOVE__((list), (ptr), LIST_NEXT_(__VA_ARGS__))) +#define SLIST_REMOVE_(list, cursor, ...) \ + LIST_BLOCK_(SLIST_REMOVE__((list), (cursor), LIST_NEXT_(__VA_ARGS__))) -#define SLIST_REMOVE__(list, ptr, next) \ - void *_next = (void *)(*ptr)->next; \ - (*ptr)->next = NULL; \ - *ptr = _next; \ - list->tail = list->head ? list->tail : &list->head; +#define SLIST_REMOVE__(list, cursor, next) \ + void *_next = (void *)(*cursor)->next; \ + (*cursor)->next = NULL; \ + *cursor = _next; \ + list->tail = _next ? list->tail : cursor; /** * Pop the head off a singly-linked list. |