cutils: list: add list_for_each_safe

For when you want to modify the list whilst iterating over it.

Change-Id: I84432892890987c218e56883c35e52c9ff0240a3
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2013-09-12 15:30:40 -07:00
parent 596e9c6314
commit 30fb83b6e5
1 changed files with 5 additions and 0 deletions

View File

@ -44,6 +44,11 @@ struct listnode
#define list_for_each_reverse(node, list) \
for (node = (list)->prev; node != (list); node = node->prev)
#define list_for_each_safe(node, next, list) \
for (node = (list)->next, next = node->next; \
node != (list); \
node = next, next = node->next)
void list_init(struct listnode *list);
void list_add_tail(struct listnode *list, struct listnode *item);
void list_remove(struct listnode *item);