summaryrefslogtreecommitdiffstats
path: root/src/list.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-01-30 12:49:28 -0500
committerTavian Barnes <tavianator@tavianator.com>2024-01-30 14:03:57 -0500
commit6f0091981e38210e36ee830694f61cb695f2b99b (patch)
tree6eb24a63df9541be0d1bde72cbd1dba55e2cdc0c /src/list.h
parent5a6cec3dff25ae3ea84a632c3b84adf68c24fce4 (diff)
downloadbfs-6f0091981e38210e36ee830694f61cb695f2b99b.tar.xz
list: Return the next cursor from SLIST_INSERT()
Diffstat (limited to 'src/list.h')
-rw-r--r--src/list.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/list.h b/src/list.h
index 02a7ba2..61d0e5b 100644
--- a/src/list.h
+++ b/src/list.h
@@ -275,6 +275,8 @@
* The item to insert.
* @param node (optional)
* If specified, use item->node.next rather than item->next.
+ * @return
+ * A cursor for the next item.
*/
#define SLIST_INSERT(list, cursor, ...) \
SLIST_INSERT_(list, cursor, __VA_ARGS__, )
@@ -282,11 +284,12 @@
#define SLIST_INSERT_(list, cursor, item, ...) \
SLIST_INSERT__((list), (cursor), (item), LIST_NEXT_(__VA_ARGS__))
-#define SLIST_INSERT__(list, cursor, item, next) LIST_VOID_( \
- bfs_assert(!SLIST_ATTACHED__(list, item, next)), \
- item->next = *cursor, \
- *cursor = item, \
- list->tail = item->next ? list->tail : &item->next)
+#define SLIST_INSERT__(list, cursor, item, next) \
+ (bfs_assert(!SLIST_ATTACHED__(list, item, next)), \
+ item->next = *cursor, \
+ *cursor = item, \
+ list->tail = item->next ? list->tail : &item->next, \
+ &item->next)
/**
* Add an item to the tail of a singly-linked list.
@@ -302,7 +305,7 @@
SLIST_APPEND_(list, __VA_ARGS__, )
#define SLIST_APPEND_(list, item, ...) \
- SLIST_INSERT_(list, (list)->tail, item, __VA_ARGS__)
+ LIST_VOID_(SLIST_INSERT_(list, (list)->tail, item, __VA_ARGS__))
/**
* Add an item to the head of a singly-linked list.
@@ -318,7 +321,7 @@
SLIST_PREPEND_(list, __VA_ARGS__, )
#define SLIST_PREPEND_(list, item, ...) \
- SLIST_INSERT_(list, &(list)->head, item, __VA_ARGS__)
+ LIST_VOID_(SLIST_INSERT_(list, &(list)->head, item, __VA_ARGS__))
/**
* Add an entire singly-linked list to the tail of another.