list: implement cds_list_for_each_safe()
A message that is not in the archive (sent off-list or not yet received): 20130313163030.GA17870@Krystal
Paul E. McKenney
Reviewed-byQuoted 7 lines · Mathieu Desnoyers
commit
7e5b9a4d1a4a63fac405ed74c42f93abdc223794Author: Mathieu Desnoyers <[email protected]> Date: Wed Mar 13 12:23:11 2013 -0400list: implement
cds_list_for_each_safe()Signed-off-by Mathieu Desnoyers <[email protected]>
Reviewed-by Paul E. McKenney <[email protected]>
Quoted 29 lines
urcu/list.h +6
-1@@ -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