Skip to contentSkip to conversation

list: implement cds_list_for_each_safe()

urcu commit Paul E. McKenney 1 participant 1 message Mar 13, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20130313163030.GA17870@Krystal

Paul E. McKenney

author Reviewed-by
#1 lore raw
Quoted 7 lines · Mathieu Desnoyers

commit 7e5b9a4d1a4a63fac405ed74c42f93abdc223794

Author: Mathieu Desnoyers <[email protected]>
Date:   Wed Mar 13 12:23:11 2013 -0400

list: implement cds_list_for_each_safe()

Quoted 29 lines
urcu/list.h +6 -1
index 5d04394..1d1c7b5 100644
@@ -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) \
Signature · 4 lines
-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com