summaryrefslogtreecommitdiff
path: root/src/shared/list.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-01-28 00:34:58 +0100
committerLennart Poettering <lennart@poettering.net>2015-01-28 00:34:58 +0100
commit7663df377016cf7b95001aec893006647175ae4a (patch)
tree523a2d1bf1787b9a3b08ae516cd54c9a022f9b73 /src/shared/list.h
parent976dec6e7b2d193533191be2969dd4eee95fc6bb (diff)
list: add macro for iterating through a list an item is in, skipping the item
Diffstat (limited to 'src/shared/list.h')
-rw-r--r--src/shared/list.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/shared/list.h b/src/shared/list.h
index f0458b54e2..7ed63188ba 100644
--- a/src/shared/list.h
+++ b/src/shared/list.h
@@ -138,6 +138,16 @@
#define LIST_FOREACH_AFTER(name,i,p) \
for ((i) = (p)->name##_next; (i); (i) = (i)->name##_next)
+/* Iterate through all the members of the list p is included in, but skip over p */
+#define LIST_FOREACH_OTHERS(name,i,p) \
+ for (({ \
+ (i) = (p); \
+ while ((i) && (i)->name##_prev) \
+ (i) = (i)->name##_prev; \
+ }); \
+ (i); \
+ (i) = (i)->name##_next == (p) ? (p)->name##_next : (i)->name##_next)
+
/* Loop starting from p->next until p->prev.
p can be adjusted meanwhile. */
#define LIST_LOOP_BUT_ONE(name,i,head,p) \