From: Juan Quintela Date: Tue, 1 Sep 2009 00:12:32 +0000 (+0200) Subject: Add LIST_FOREACH_SAFE() definition X-Git-Url: https://repo.jachan.dev/qemu.git/commitdiff_plain/bb150dc82f089c33e688694baa34a03377fcfda8 Add LIST_FOREACH_SAFE() definition Signed-off-by: Juan Quintela Signed-off-by: Anthony Liguori --- diff --git a/sys-queue.h b/sys-queue.h index cb6a4c8906..eb89a4d217 100644 --- a/sys-queue.h +++ b/sys-queue.h @@ -126,6 +126,11 @@ struct { \ (var); \ (var) = ((var)->field.le_next)) +#define LIST_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->lh_first); \ + (var) && ((next_var) = ((var)->field.le_next), 1); \ + (var) = (next_var)) + /* * List access methods. */