summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-10-17 10:05:50 +0200
committerThomas Haller <thaller@redhat.com>2019-10-18 22:09:18 +0200
commit308beb85fed82a210f32c2770abf69962caff2eb (patch)
tree1493018fb4ad8d59da1e1a1e2cf296ebd2fe4b61
parentc02710bb0f64ab94e777be1641c380ff81fe14ce (diff)
downloadNetworkManager-308beb85fed82a210f32c2770abf69962caff2eb.tar.gz
shared: add nm_c_list_for_each_entry_prev() helper macro
It's non-trivial to get this right. Add the macro for iterating the list in reverse.
-rw-r--r--shared/nm-glib-aux/nm-c-list.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-c-list.h b/shared/nm-glib-aux/nm-c-list.h
index 7a6e8ccaf2..256dda74fb 100644
--- a/shared/nm-glib-aux/nm-c-list.h
+++ b/shared/nm-glib-aux/nm-c-list.h
@@ -17,6 +17,12 @@
_what && c_list_contains (list, &_what->member); \
})
+/* iterate over the list backwards. */
+#define nm_c_list_for_each_entry_prev(_iter, _list, _m) \
+ for (_iter = c_list_entry ((_list)->prev, __typeof__ (*_iter), _m); \
+ &(_iter)->_m != (_list); \
+ _iter = c_list_entry ((_iter)->_m.prev, __typeof__ (*_iter), _m))
+
/*****************************************************************************/
typedef struct {