diff options
Diffstat (limited to 'utils.h')
-rw-r--r-- | utils.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); |