From 341ba0f69666efa90332dabda22b20e54631d7c7 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 29 Aug 2005 12:18:15 +0000 Subject: [PATCH] Added a LIST_FOR_EACH_ENTRY_SAFE helper macro. --- include/wine/list.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/wine/list.h b/include/wine/list.h index 46327d8f1b7..7d33a2300ee 100644 --- a/include/wine/list.h +++ b/include/wine/list.h @@ -155,6 +155,14 @@ inline static void list_init( struct list *list ) &(elem)->field != (list); \ (elem) = LIST_ENTRY((elem)->field.next, type, field)) +/* iterate through the list using a list entry, with safety against removal */ +#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field) \ + for ((cursor) = LIST_ENTRY((list)->next, type, field), \ + (cursor2) = LIST_ENTRY((cursor)->field.next, type, field); \ + &(cursor)->field != (list); \ + (cursor) = (cursor2), \ + (cursor2) = LIST_ENTRY((cursor)->field.next, type, field)) + /* macros for statically initialized lists */ #define LIST_INIT(list) { &(list), &(list) }