misc: add safe list iterator

New for-each implementation that keeps a safe pointer to the next element
so you can remove the current element from the list.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-05-05 17:14:28 +02:00
parent f7b398a34a
commit 23e9903f07

View File

@ -154,4 +154,8 @@ static inline bool kmscon_dlist_empty(struct kmscon_dlist *head)
#define kmscon_dlist_for_each(iter, head) \
for (iter = (head)->next; iter != (head); iter = iter->next)
#define kmscon_dlist_for_each_safe(iter, tmp, head) \
for (iter = (head)->next, tmp = iter->next; iter != (head); \
iter = tmp, tmp = iter->next)
#endif /* KMSCON_MISC_H */