diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-09-25 13:29:03 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-09-25 13:29:03 -0400 |
commit | 4343832097996886d085fe1139abcec363afc9ee (patch) | |
tree | 454ff289c71d895d3a0ab1a8561a8567d915dc51 | |
parent | 72ea07d8c200bd6cd34ce02121165f3888624ac6 (diff) | |
download | bfs-4343832097996886d085fe1139abcec363afc9ee.tar.xz |
list: New [S]LIST_EMPTY() macros
-rw-r--r-- | src/list.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -188,6 +188,15 @@ LIST_VOID_(item->next = NULL) /** + * Check if a singly-linked list is empty. + */ +#define SLIST_EMPTY(list) \ + SLIST_EMPTY_((list)) + +#define SLIST_EMPTY_(list) \ + ((void)sizeof(list->tail - &list->head), !list->head) + +/** * Insert an item into a singly-linked list. * * @param list @@ -336,6 +345,15 @@ static inline void *slist_remove_impl(void *ret, void *cursor, void *next, void LIST_VOID_(item->prev = item->next = NULL) /** + * Check if a doubly-linked list is empty. + */ +#define LIST_EMPTY(list) \ + LIST_EMPTY_((list)) + +#define LIST_EMPTY_(list) \ + ((void)sizeof(list->tail - list->head), !list->head) + +/** * Add an item to the tail of a doubly-linked list. * * @param list |