diff options
author | Thomas Haller <thaller@redhat.com> | 2019-02-12 11:03:56 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-02-18 15:00:10 +0100 |
commit | a85318f8def2623b7090983fb25fd476720936a3 (patch) | |
tree | b40342b7b6c7bb56d18dc5de88673f55697cac63 | |
parent | 080f5ee76b037287ca7d104c8a2e4d3df265278e (diff) | |
download | NetworkManager-a85318f8def2623b7090983fb25fd476720936a3.tar.gz |
shared: add nm_c_list_move_*() helpers
-rw-r--r-- | shared/nm-utils/nm-c-list.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-c-list.h b/shared/nm-utils/nm-c-list.h index b43d144197..5c73f57475 100644 --- a/shared/nm-utils/nm-c-list.h +++ b/shared/nm-utils/nm-c-list.h @@ -78,4 +78,40 @@ nm_c_list_elem_free_all (CList *head, GDestroyNotify free_fcn) } } +/*****************************************************************************/ + +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) { + c_list_unlink_stale (elem); + c_list_link_before (lst, elem); + return TRUE; + } + return FALSE; +} +#define nm_c_list_move_tail(lst, elem) nm_c_list_move_before (lst, elem) + +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) { + c_list_unlink_stale (elem); + c_list_link_after (lst, elem); + return TRUE; + } + return FALSE; +} +#define nm_c_list_move_front(lst, elem) nm_c_list_move_after (lst, elem) + #endif /* __NM_C_LIST_H__ */ |