shared: add nm_utils_strv_find_binary_search() helper

This commit is contained in:
Thomas Haller 2021-03-15 14:41:11 +01:00
parent e4aa3f4b2d
commit ca869bff9f
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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,