summaryrefslogtreecommitdiff
path: root/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils.h')
-rw-r--r--utils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils.h b/utils.h
index 250dbdc..f02c47a 100644
--- a/utils.h
+++ b/utils.h
@@ -10,6 +10,10 @@ struct list_head {
struct list_head *prev;
};
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name)
+
static inline void list_init(struct list_head *list)
{
list->next = list;
@@ -69,6 +73,12 @@ static inline bool list_empty(struct list_head *list)
&pos->member != (head); \
pos = list_next_entry(pos, member))
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
static inline void* zmalloc(size_t size)
{
return calloc(1, size);