diff options
author | Thomas Haller <thaller@redhat.com> | 2019-06-21 14:45:07 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-06-26 09:53:54 +0200 |
commit | fcaf7994f2011b38487c472b6ebfee78bf1a8140 (patch) | |
tree | bf62796695857d04dee2de01bc745d1e9b9f1a8a /shared | |
parent | bf6e902c90129a86efd2e2ae223256ca30267450 (diff) | |
download | NetworkManager-fcaf7994f2011b38487c472b6ebfee78bf1a8140.tar.gz |
shared: allow nm_c_list_move_*() API also to move from one list to another
Previously, nm_c_list_move_*() only allowed to move element inside the
same list. Relax that, it works just the same list to move the element
from one list into a different list.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/nm-glib-aux/nm-c-list.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/shared/nm-glib-aux/nm-c-list.h b/shared/nm-glib-aux/nm-c-list.h index d835bbc1d4..36f1ff755b 100644 --- a/shared/nm-glib-aux/nm-c-list.h +++ b/shared/nm-glib-aux/nm-c-list.h @@ -101,12 +101,24 @@ nm_c_list_elem_find_first (CList *head, gconstpointer needle) /*****************************************************************************/ +/** + * nm_c_list_move_before: + * @lst: the list element to which @elem will be prepended. + * @elem: the list element to move. + * + * This unlinks @elem from the current list and linkes it before + * @lst. This is like c_list_link_before(), except that @elem must + * be initialized and linked. Note that @elem may be linked in @lst + * or in another list. In both cases it gets moved. + * + * Returns: %TRUE if there were any changes. %FALSE if elem was already + * linked at the right place. + */ static inline gboolean nm_c_list_move_before (CList *lst, CList *elem) { nm_assert (lst); nm_assert (elem); - nm_assert (c_list_contains (lst, elem)); if ( lst != elem && lst->prev != elem) { @@ -118,12 +130,24 @@ nm_c_list_move_before (CList *lst, CList *elem) } #define nm_c_list_move_tail(lst, elem) nm_c_list_move_before (lst, elem) +/** + * nm_c_list_move_after: + * @lst: the list element to which @elem will be prepended. + * @elem: the list element to move. + * + * This unlinks @elem from the current list and linkes it after + * @lst. This is like c_list_link_after(), except that @elem must + * be initialized and linked. Note that @elem may be linked in @lst + * or in another list. In both cases it gets moved. + * + * Returns: %TRUE if there were any changes. %FALSE if elem was already + * linked at the right place. + */ static inline gboolean nm_c_list_move_after (CList *lst, CList *elem) { nm_assert (lst); nm_assert (elem); - nm_assert (c_list_contains (lst, elem)); if ( lst != elem && lst->next != elem) { |