diff options
author | Thomas Haller <thaller@redhat.com> | 2021-03-15 14:41:11 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-03-16 09:55:47 +0100 |
commit | ca869bff9f79025362cc7a55c5ebdc8e8cf10424 (patch) | |
tree | 7c10267340ef0df12a5b54735c2deaead830fb5c | |
parent | e4aa3f4b2d6ca94cfc3050e17ffe5eeaf0e91187 (diff) | |
download | NetworkManager-ca869bff9f79025362cc7a55c5ebdc8e8cf10424.tar.gz |
shared: add nm_utils_strv_find_binary_search() helper
-rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index e28a6f825e..db816a8c10 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -2020,6 +2020,24 @@ gssize nm_utils_ptrarray_find_binary_search(gconstpointer * list, gssize * out_idx_first, gssize * out_idx_last); +#define nm_utils_strv_find_binary_search(strv, len, needle) \ + ({ \ + const char *const *const _strv = NM_CAST_STRV_CC(strv); \ + const gsize _len = (len); \ + const char *const _needle = (needle); \ + \ + nm_assert(_len == 0 || _strv); \ + nm_assert(_needle); \ + \ + nm_utils_ptrarray_find_binary_search((gconstpointer *) _strv, \ + _len, \ + _needle, \ + nm_strcmp_with_data, \ + NULL, \ + NULL, \ + NULL); \ + }) + gssize nm_utils_array_find_binary_search(gconstpointer list, gsize elem_size, gsize len, |