list: implement cds_list_for_each_safe()
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Mar 2013 16:23:11 +0000 (12:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Mar 2013 16:23:11 +0000 (12:23 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu/list.h

index 5d04394f5295ac15f7593bb54fd0b5c26f4798c7..1d1c7b5ce2882b6bd0e13b53b096c081dbcb1b44 100644 (file)
@@ -140,12 +140,17 @@ cds_list_splice (struct cds_list_head *add, struct cds_list_head *head)
 #define cds_list_for_each(pos, head) \
   for (pos = (head)->next; pos != (head); pos = pos->next)
 
+/* Iterate forward over the elements list. The list elements can be
+   removed from the list while doing this.  */
+#define cds_list_for_each_safe(pos, p, head) \
+  for (pos = (head)->next, p = pos->next; \
+       pos != (head); \
+       pos = p, p = pos->next)
 
 /* Iterate backward over the elements of the list.  */
 #define cds_list_for_each_prev(pos, head) \
   for (pos = (head)->prev; pos != (head); pos = pos->prev)
 
-
 /* Iterate backwards over the elements list.  The list elements can be
    removed from the list while doing this.  */
 #define cds_list_for_each_prev_safe(pos, p, head) \
This page took 0.02491 seconds and 4 git commands to generate.