Add TAILQ iterator that allows to safely remove elements while walking
the list.

Signed-off-by: Jan Kiszka <[EMAIL PROTECTED]>
---

 qemu/sys-queue.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/qemu/sys-queue.h b/qemu/sys-queue.h
index 3d0773e..ad5c8fb 100644
--- a/qemu/sys-queue.h
+++ b/qemu/sys-queue.h
@@ -210,6 +210,11 @@ struct {                                                   
             \
                 (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);                                                  \

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to