mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 16:00:21 +01:00
shared: add nm_utils_strv_find_binary_search() helper
This commit is contained in:
parent
e4aa3f4b2d
commit
ca869bff9f
1 changed files with 18 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue