aboutsummaryrefslogtreecommitdiff
path: root/sys-queue.h
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-11-25 22:05:37 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-11-25 22:05:37 +0000
commit31280d92d1cfd31743ebde611ad48d92239ca9aa (patch)
treef525d8f53556300eec6bf95f77a51c1f4f08fced /sys-queue.h
parentf3d54fc4948b5525cc15e2a082f0cec8610ec5b4 (diff)
downloadqemu-31280d92d1cfd31743ebde611ad48d92239ca9aa.zip
qemu-31280d92d1cfd31743ebde611ad48d92239ca9aa.tar.gz
qemu-31280d92d1cfd31743ebde611ad48d92239ca9aa.tar.bz2
Add TAILQ_FOREACH_SAFE (Jan Kiszka)
Add TAILQ iterator that allows to safely remove elements while walking the list. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5798 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'sys-queue.h')
-rw-r--r--sys-queue.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys-queue.h b/sys-queue.h
index 3d0773e..ad5c8fb 100644
--- a/sys-queue.h
+++ b/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); \