cyberslak
/lightsout
/amendments
/6
list: add list_foreach and list_init
cyberslak made amendment 6 25 days ago
--- list.h Mon Mar 3 23:20:46 2025
+++ list.h Fri Mar 7 23:21:34 2025
@@ -15,6 +15,14 @@ typedef struct list
#define container_of(ptr, ty, field) \
((ty*)((char*)(ptr)-offsetof(ty, field)))
+
+#define list_foreach(head, node) \
+ for (node = (head)->next; node != (head); node = (node)->next)
+
+static inline void list_init(list_t* lst)
+{
+ lst->next = lst->prev = lst;
+}
static inline short list_empty(list_t* head)
{