[5798] Add TAILQ_FOREACH_SAFE (Jan Kiszka)
Revision: 5798
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5798 Author: aliguori Date: 2008-11-25 22:05:37 +0000 (Tue, 25 Nov 2008)
Log Message:
-----------
Add TAILQ_FOREACH_SAFE (Jan Kiszka)
Add TAILQ iterator that allows to safely remove elements while walking the list.
Signed-off-by Jan Kiszka <[email protected]>
Signed-off-by Anthony Liguori <[email protected]>
Modified Paths:
--------------
trunk/sys-queue.h
Modified: trunk/sys-queue.h
===================================================================
sys-queue.h +5 -0
@@ -210,6 +210,11 @@ (var); \ (var) = ((var)->field.tqe_next)) +#define TAILQ_FOREACH_SAFE (var, head, field, next_var) \ + for ((var) = ((head)->tqh_first); \ + (var) && ((next_var) = ((var)->field.tqe_next), 1); \ + (var) = (next_var)) +#define TAILQ_FOREACH_REVERSE (var, head, headname, field) \ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ (var); \