Commit 31280d92d1cfd31743ebde611ad48d92239ca9aa

Authored by aliguori
1 parent f3d54fc4

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
Showing 1 changed file with 5 additions and 0 deletions
sys-queue.h
... ... @@ -210,6 +210,11 @@ struct { \
210 210 (var); \
211 211 (var) = ((var)->field.tqe_next))
212 212  
  213 +#define TAILQ_FOREACH_SAFE(var, head, field, next_var) \
  214 + for ((var) = ((head)->tqh_first); \
  215 + (var) && ((next_var) = ((var)->field.tqe_next), 1); \
  216 + (var) = (next_var))
  217 +
213 218 #define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
214 219 for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
215 220 (var); \
... ...