Add LIST_FOR_EACH_SAFE - a list iteration macro that is safe against
removal.
This commit is contained in:
parent
89f5c8241f
commit
e1d2a837a0
|
@ -143,6 +143,12 @@ inline static void list_init( struct list *list )
|
||||||
#define LIST_FOR_EACH(cursor,list) \
|
#define LIST_FOR_EACH(cursor,list) \
|
||||||
for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
|
for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
|
||||||
|
|
||||||
|
/* iterate through the list, with safety against removal */
|
||||||
|
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list) \
|
||||||
|
for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \
|
||||||
|
(cursor) != (list); \
|
||||||
|
(cursor) = (cursor2), (cursor2) = (cursor)->next)
|
||||||
|
|
||||||
/* macros for statically initialized lists */
|
/* macros for statically initialized lists */
|
||||||
#define LIST_INIT(list) { &(list), &(list) }
|
#define LIST_INIT(list) { &(list), &(list) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue