chiark / gitweb /
journal: loop less in MATCH_AND_TERM conditionals
[elogind.git] / src / shared / list.h
index 47f275a019403c873d0d52341f7ab93fdb120d48..96d6237974726693512b71cbc12c12e9df7bcf4e 100644 (file)
 
 #define LIST_FOREACH_AFTER(name,i,p)                                    \
         for ((i) = (p)->name##_next; (i); (i) = (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)                                \
+        for ((i) = (p)->name##_next ? (p)->name##_next : (head);        \
+             (i) != (p);                                                \
+             (i) = (i)->name##_next ? (i)->name##_next : (head))