diff options
author | Thomas Haller <thaller@redhat.com> | 2019-10-17 10:05:50 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-10-18 22:09:18 +0200 |
commit | 308beb85fed82a210f32c2770abf69962caff2eb (patch) | |
tree | 1493018fb4ad8d59da1e1a1e2cf296ebd2fe4b61 | |
parent | c02710bb0f64ab94e777be1641c380ff81fe14ce (diff) | |
download | NetworkManager-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.h | 6 |
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 { |