From: Mathieu Desnoyers Date: Wed, 13 Mar 2013 16:23:11 +0000 (-0400) Subject: list: implement cds_list_for_each_safe() X-Git-Tag: v0.8.0~101 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7e5b9a4d1a4a63fac405ed74c42f93abdc223794;p=userspace-rcu.git list: implement cds_list_for_each_safe() Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu/list.h b/urcu/list.h index 5d04394..1d1c7b5 100644 --- a/urcu/list.h +++ b/urcu/list.h @@ -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) \