summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-04-01 18:09:48 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-04-01 18:09:48 -0400
commitc4a4d397ccc124f50b851cfa52b9937ba7485b2b (patch)
tree0643ade6b2ccda7f0b9f270ad2c4a6b82cbf9994 /src
parentecbc4a7572cb67802b1cb99d8914c19f1fb4f2c4 (diff)
downloadbfs-c4a4d397ccc124f50b851cfa52b9937ba7485b2b.tar.xz
list: Fix SLIST_REMOVE() on the tail
Diffstat (limited to 'src')
-rw-r--r--src/list.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/list.h b/src/list.h
index 08f97ab..a674aaf 100644
--- a/src/list.h
+++ b/src/list.h
@@ -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.