Add LIST_FOREACH_SAFE, which is like LIST_FOREACH but allows you
to walk the list and remove the current item and destroy/free it. Alexander Kabaev will likely do the equivalent for the other list types, but I just happened to have this one sitting in a local non-FreeBSD tree already.
This commit is contained in:
parent
5105f9919f
commit
0373e754d6
@ -325,6 +325,13 @@ struct { \
|
||||
(var); \
|
||||
(var) = LIST_NEXT((var), field))
|
||||
|
||||
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = LIST_FIRST((head)), \
|
||||
(var) != NULL ? (tvar) = LIST_NEXT((var), field) : NULL; \
|
||||
(var) != NULL; \
|
||||
(var) = (tvar), \
|
||||
(var) != NULL ? (tvar) = LIST_NEXT((var), field) : NULL)
|
||||
|
||||
#define LIST_INIT(head) do { \
|
||||
LIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user