From 7e5b9a4d1a4a63fac405ed74c42f93abdc223794 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 13 Mar 2013 12:23:11 -0400 Subject: [PATCH] list: implement cds_list_for_each_safe() Signed-off-by: Mathieu Desnoyers --- urcu/list.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) \ -- 2.34.1