Add LIST_FOR_EACH_SAFE - a list iteration macro that is safe against
authorRobert Shearman <rob@codeweavers.com>
Wed, 12 Jan 2005 19:27:35 +0000 (19:27 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 12 Jan 2005 19:27:35 +0000 (19:27 +0000)
removal.

include/wine/list.h

index 6d27fad62300d248ff37a308a41e7d1a75cb03d9..558cb371407e6603d35f412f85e998081cfd4baf 100644 (file)
@@ -143,6 +143,12 @@ inline static void list_init( struct list *list )
 #define LIST_FOR_EACH(cursor,list) \
     for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
 
+/* iterate through the list, with safety against removal */
+#define LIST_FOR_EACH_SAFE(cursor, cursor2, list) \
+    for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \
+         (cursor) != (list); \
+         (cursor) = (cursor2), (cursor2) = (cursor)->next)
+
 /* macros for statically initialized lists */
 #define LIST_INIT(list)  { &(list), &(list) }