mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-12 06:30:39 +01:00
all: merge branch 'th/array-find-bsearch'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1397
This commit is contained in:
commit
af85961ea1
16 changed files with 160 additions and 171 deletions
|
|
@ -7904,12 +7904,12 @@ nm_manager_set_capability(NMManager *self, NMCapability cap)
|
|||
|
||||
priv = NM_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
idx = nm_utils_array_find_binary_search(nm_g_array_index_p(priv->capabilities, guint32, 0),
|
||||
sizeof(guint32),
|
||||
priv->capabilities->len,
|
||||
&cap_i,
|
||||
nm_cmp_uint32_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(nm_g_array_index_p(priv->capabilities, guint32, 0),
|
||||
priv->capabilities->len,
|
||||
sizeof(guint32),
|
||||
&cap_i,
|
||||
nm_cmp_uint32_p_with_data,
|
||||
NULL);
|
||||
if (idx >= 0)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -1080,12 +1080,12 @@ nms_ifcfg_well_known_key_find_info(const char *key, gssize *out_idx)
|
|||
|
||||
G_STATIC_ASSERT(G_STRUCT_OFFSET(NMSIfcfgKeyTypeInfo, key_name) == 0);
|
||||
|
||||
idx = nm_utils_array_find_binary_search(nms_ifcfg_well_known_keys,
|
||||
sizeof(nms_ifcfg_well_known_keys[0]),
|
||||
G_N_ELEMENTS(nms_ifcfg_well_known_keys),
|
||||
&key,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(nms_ifcfg_well_known_keys,
|
||||
G_N_ELEMENTS(nms_ifcfg_well_known_keys),
|
||||
sizeof(nms_ifcfg_well_known_keys[0]),
|
||||
&key,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
NM_SET_OUT(out_idx, idx);
|
||||
if (idx < 0)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -279,12 +279,12 @@ nm_supplicant_settings_verify_setting(const char *key, const char *value, const
|
|||
}
|
||||
}
|
||||
|
||||
opt_idx = nm_utils_array_find_binary_search(opt_table,
|
||||
sizeof(opt_table[0]),
|
||||
G_N_ELEMENTS(opt_table),
|
||||
&key,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
opt_idx = nm_array_find_bsearch(opt_table,
|
||||
G_N_ELEMENTS(opt_table),
|
||||
sizeof(opt_table[0]),
|
||||
&key,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
if (opt_idx < 0) {
|
||||
if (nm_streq(key, "mode")) {
|
||||
if (len != 1)
|
||||
|
|
|
|||
|
|
@ -271,12 +271,12 @@ nm_ethtool_data_get_by_optname(const char *optname)
|
|||
|
||||
_ASSERT_data();
|
||||
|
||||
idx = nm_utils_array_find_binary_search((gconstpointer *) _by_name,
|
||||
sizeof(_by_name[0]),
|
||||
_NM_ETHTOOL_ID_NUM,
|
||||
optname,
|
||||
_by_name_cmp,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch((gconstpointer *) _by_name,
|
||||
_NM_ETHTOOL_ID_NUM,
|
||||
sizeof(_by_name[0]),
|
||||
optname,
|
||||
_by_name_cmp,
|
||||
NULL);
|
||||
return (idx < 0) ? NULL : nm_ethtool_data[_by_name[idx]];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -752,11 +752,11 @@ nml_dbus_meta_iface_get(const char *dbus_iface_name)
|
|||
|
||||
if (NM_STR_HAS_PREFIX(dbus_iface_name, COMMON_PREFIX)) {
|
||||
/* optimize, that in fact all our interfaces have the same prefix. */
|
||||
idx = nm_utils_ptrarray_find_binary_search((gconstpointer *) _nml_dbus_meta_ifaces,
|
||||
G_N_ELEMENTS(_nml_dbus_meta_ifaces),
|
||||
&dbus_iface_name[NM_STRLEN(COMMON_PREFIX)],
|
||||
_strcmp_common_prefix,
|
||||
NULL);
|
||||
idx = nm_ptrarray_find_bsearch((gconstpointer *) _nml_dbus_meta_ifaces,
|
||||
G_N_ELEMENTS(_nml_dbus_meta_ifaces),
|
||||
&dbus_iface_name[NM_STRLEN(COMMON_PREFIX)],
|
||||
_strcmp_common_prefix,
|
||||
NULL);
|
||||
} else
|
||||
return NULL;
|
||||
|
||||
|
|
@ -775,12 +775,12 @@ nml_dbus_meta_property_get(const NMLDBusMetaIface *meta_iface,
|
|||
nm_assert(meta_iface);
|
||||
nm_assert(dbus_property_name);
|
||||
|
||||
idx = nm_utils_array_find_binary_search(meta_iface->dbus_properties,
|
||||
sizeof(meta_iface->dbus_properties[0]),
|
||||
meta_iface->n_dbus_properties,
|
||||
&dbus_property_name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(meta_iface->dbus_properties,
|
||||
meta_iface->n_dbus_properties,
|
||||
sizeof(meta_iface->dbus_properties[0]),
|
||||
&dbus_property_name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
if (idx < 0) {
|
||||
NM_SET_OUT(out_idx, meta_iface->n_dbus_properties);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -349,12 +349,12 @@ nm_auth_permission_from_string(const char *str)
|
|||
|
||||
if (!NM_STR_HAS_PREFIX(str, AUTH_PERMISSION_PREFIX))
|
||||
return NM_CLIENT_PERMISSION_NONE;
|
||||
idx = nm_utils_array_find_binary_search(nm_auth_permission_sorted,
|
||||
sizeof(nm_auth_permission_sorted[0]),
|
||||
G_N_ELEMENTS(nm_auth_permission_sorted),
|
||||
&str[NM_STRLEN(AUTH_PERMISSION_PREFIX)],
|
||||
_nm_auth_permission_from_string_cmp,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(nm_auth_permission_sorted,
|
||||
G_N_ELEMENTS(nm_auth_permission_sorted),
|
||||
sizeof(nm_auth_permission_sorted[0]),
|
||||
&str[NM_STRLEN(AUTH_PERMISSION_PREFIX)],
|
||||
_nm_auth_permission_from_string_cmp,
|
||||
NULL);
|
||||
if (idx < 0)
|
||||
return NM_CLIENT_PERMISSION_NONE;
|
||||
return nm_auth_permission_sorted[idx];
|
||||
|
|
|
|||
|
|
@ -3188,11 +3188,11 @@ _parse_info_find(NMSetting *setting,
|
|||
|
||||
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(ParseInfoProperty, property_name) == 0);
|
||||
|
||||
idx = nm_utils_ptrarray_find_binary_search((gconstpointer *) pis->properties,
|
||||
NM_PTRARRAY_LEN(pis->properties),
|
||||
&property_name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_ptrarray_find_bsearch((gconstpointer *) pis->properties,
|
||||
NM_PTRARRAY_LEN(pis->properties),
|
||||
&property_name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
if (idx >= 0)
|
||||
pip = pis->properties[idx];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -693,12 +693,12 @@ nm_meta_setting_infos_by_name(const char *name)
|
|||
}
|
||||
|
||||
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMMetaSettingInfo, setting_name) == 0);
|
||||
idx = nm_utils_array_find_binary_search(nm_meta_setting_infos,
|
||||
sizeof(NMMetaSettingInfo),
|
||||
_NM_META_SETTING_TYPE_NUM,
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(nm_meta_setting_infos,
|
||||
_NM_META_SETTING_TYPE_NUM,
|
||||
sizeof(NMMetaSettingInfo),
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
|
||||
return idx >= 0 ? &nm_meta_setting_infos[idx] : NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2934,12 +2934,12 @@ _rr_dbus_attr_from_name(const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
idx = nm_utils_array_find_binary_search(rr_dbus_data,
|
||||
sizeof(rr_dbus_data[0]),
|
||||
_RR_DBUS_ATTR_NUM,
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(rr_dbus_data,
|
||||
_RR_DBUS_ATTR_NUM,
|
||||
sizeof(rr_dbus_data[0]),
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
if (idx < 0)
|
||||
return _RR_DBUS_ATTR_NUM;
|
||||
return idx;
|
||||
|
|
|
|||
|
|
@ -477,12 +477,12 @@ _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info,
|
|||
return NULL;
|
||||
|
||||
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMSettInfoProperty, name) == 0);
|
||||
idx = nm_utils_array_find_binary_search(sett_info->property_infos,
|
||||
sizeof(NMSettInfoProperty),
|
||||
sett_info->property_infos_len,
|
||||
&property_name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(sett_info->property_infos,
|
||||
sett_info->property_infos_len,
|
||||
sizeof(NMSettInfoProperty),
|
||||
&property_name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
|
||||
if (idx < 0)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -5020,11 +5020,8 @@ _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *cons
|
|||
|
||||
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMVariantAttributeSpec, name) == 0);
|
||||
|
||||
idx = nm_utils_ptrarray_find_binary_search((gconstpointer *) array,
|
||||
len,
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx =
|
||||
nm_ptrarray_find_bsearch((gconstpointer *) array, len, &name, nm_strcmp_p_with_data, NULL);
|
||||
if (idx < 0)
|
||||
return NULL;
|
||||
return array[idx];
|
||||
|
|
|
|||
|
|
@ -8784,19 +8784,15 @@ _test_find_binary_search_do(const int *array, gsize len)
|
|||
|
||||
expected_result = nm_utils_ptrarray_find_first(parray, len, pneedle);
|
||||
|
||||
idx = nm_utils_ptrarray_find_binary_search_range(parray,
|
||||
len,
|
||||
pneedle,
|
||||
_test_find_binary_search_cmp,
|
||||
NULL,
|
||||
&idx_first,
|
||||
&idx_last);
|
||||
idx = nm_ptrarray_find_bsearch_range(parray,
|
||||
len,
|
||||
pneedle,
|
||||
_test_find_binary_search_cmp,
|
||||
NULL,
|
||||
&idx_first,
|
||||
&idx_last);
|
||||
|
||||
idx2 = nm_utils_ptrarray_find_binary_search(parray,
|
||||
len,
|
||||
pneedle,
|
||||
_test_find_binary_search_cmp,
|
||||
NULL);
|
||||
idx2 = nm_ptrarray_find_bsearch(parray, len, pneedle, _test_find_binary_search_cmp, NULL);
|
||||
g_assert_cmpint(idx, ==, idx2);
|
||||
|
||||
if (expected_result >= 0) {
|
||||
|
|
@ -8861,12 +8857,12 @@ _test_find_binary_search_do_uint32(const int *int_array, gsize len)
|
|||
expected_result = idx;
|
||||
}
|
||||
|
||||
idx = nm_utils_array_find_binary_search(array,
|
||||
sizeof(guint32),
|
||||
len,
|
||||
&NEEDLE,
|
||||
nm_cmp_uint32_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(array,
|
||||
len,
|
||||
sizeof(guint32),
|
||||
&NEEDLE,
|
||||
nm_cmp_uint32_p_with_data,
|
||||
NULL);
|
||||
if (expected_result >= 0)
|
||||
g_assert_cmpint(expected_result, ==, idx);
|
||||
else {
|
||||
|
|
@ -8960,29 +8956,25 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates(void)
|
|||
for (i = 0; i < i_len + BIN_SEARCH_W_DUPS_JITTER; i++) {
|
||||
gconstpointer p = GINT_TO_POINTER(i);
|
||||
|
||||
idx = nm_utils_ptrarray_find_binary_search_range(arr,
|
||||
i_len,
|
||||
p,
|
||||
_test_bin_search2_cmp,
|
||||
NULL,
|
||||
&idx_first,
|
||||
&idx_last);
|
||||
idx = nm_ptrarray_find_bsearch_range(arr,
|
||||
i_len,
|
||||
p,
|
||||
_test_bin_search2_cmp,
|
||||
NULL,
|
||||
&idx_first,
|
||||
&idx_last);
|
||||
|
||||
idx_first2 = nm_utils_ptrarray_find_first(arr, i_len, p);
|
||||
|
||||
idx2 = nm_utils_array_find_binary_search(arr,
|
||||
sizeof(gpointer),
|
||||
i_len,
|
||||
&p,
|
||||
_test_bin_search2_cmp_p,
|
||||
NULL);
|
||||
idx2 = nm_array_find_bsearch(arr,
|
||||
i_len,
|
||||
sizeof(gpointer),
|
||||
&p,
|
||||
_test_bin_search2_cmp_p,
|
||||
NULL);
|
||||
g_assert_cmpint(idx, ==, idx2);
|
||||
|
||||
idx2 = nm_utils_ptrarray_find_binary_search(arr,
|
||||
i_len,
|
||||
p,
|
||||
_test_bin_search2_cmp,
|
||||
NULL);
|
||||
idx2 = nm_ptrarray_find_bsearch(arr, i_len, p, _test_bin_search2_cmp, NULL);
|
||||
g_assert_cmpint(idx, ==, idx2);
|
||||
|
||||
if (idx_first2 < 0) {
|
||||
|
|
@ -11254,7 +11246,7 @@ main(int argc, char **argv)
|
|||
|
||||
g_test_add_func("/core/general/_nm_utils_ascii_str_to_int64", test_nm_utils_ascii_str_to_int64);
|
||||
g_test_add_func("/core/general/nm_utils_is_power_of_two", test_nm_utils_is_power_of_two);
|
||||
g_test_add_func("/core/general/nm_utils_ptrarray_find_binary_search_range",
|
||||
g_test_add_func("/core/general/nm_ptrarray_find_bsearch_range",
|
||||
test_nm_utils_ptrarray_find_binary_search);
|
||||
g_test_add_func("/core/general/nm_utils_ptrarray_find_binary_search_with_duplicates",
|
||||
test_nm_utils_ptrarray_find_binary_search_with_duplicates);
|
||||
|
|
|
|||
|
|
@ -3093,12 +3093,12 @@ nm_utils_named_value_list_find(const NMUtilsNamedValue *arr,
|
|||
#endif
|
||||
|
||||
if (sorted) {
|
||||
return nm_utils_array_find_binary_search(arr,
|
||||
sizeof(NMUtilsNamedValue),
|
||||
len,
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
return nm_array_find_bsearch(arr,
|
||||
len,
|
||||
sizeof(NMUtilsNamedValue),
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
if (nm_streq(arr[i].name, name))
|
||||
|
|
@ -3786,11 +3786,11 @@ nm_utils_ptrarray_is_sorted(gconstpointer *list,
|
|||
}
|
||||
|
||||
gssize
|
||||
nm_utils_ptrarray_find_binary_search(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
nm_ptrarray_find_bsearch(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
{
|
||||
gssize imin, imax, imid;
|
||||
int cmp;
|
||||
|
|
@ -3823,13 +3823,13 @@ nm_utils_ptrarray_find_binary_search(gconstpointer *list,
|
|||
}
|
||||
|
||||
gssize
|
||||
nm_utils_ptrarray_find_binary_search_range(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data,
|
||||
gssize *out_idx_first,
|
||||
gssize *out_idx_last)
|
||||
nm_ptrarray_find_bsearch_range(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data,
|
||||
gssize *out_idx_first,
|
||||
gssize *out_idx_last)
|
||||
{
|
||||
gssize imin, imax, imid, i2min, i2max, i2mid;
|
||||
int cmp;
|
||||
|
|
@ -3904,10 +3904,10 @@ nm_utils_ptrarray_find_binary_search_range(gconstpointer *list,
|
|||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_utils_array_find_binary_search:
|
||||
* nm_array_find_bsearch:
|
||||
* @list: the list to search. It must be sorted according to @cmpfcn ordering.
|
||||
* @elem_size: the size in bytes of each element in the list
|
||||
* @len: the number of elements in @list
|
||||
* @elem_size: the size in bytes of each element in the list
|
||||
* @needle: the value that is searched
|
||||
* @cmpfcn: the compare function. The elements @list are passed as first
|
||||
* argument to @cmpfcn, while @needle is passed as second. Usually, the
|
||||
|
|
@ -3928,12 +3928,12 @@ nm_utils_ptrarray_find_binary_search_range(gconstpointer *list,
|
|||
* position where it should be.
|
||||
*/
|
||||
gssize
|
||||
nm_utils_array_find_binary_search(gconstpointer list,
|
||||
gsize elem_size,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
nm_array_find_bsearch(gconstpointer list,
|
||||
gsize len,
|
||||
gsize elem_size,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data)
|
||||
{
|
||||
gssize imin, imax, imid;
|
||||
int cmp;
|
||||
|
|
|
|||
|
|
@ -2103,42 +2103,42 @@ gboolean nm_utils_ptrarray_is_sorted(gconstpointer *list,
|
|||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data);
|
||||
|
||||
gssize nm_utils_ptrarray_find_binary_search(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data);
|
||||
gssize nm_ptrarray_find_bsearch(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data);
|
||||
|
||||
gssize nm_utils_ptrarray_find_binary_search_range(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data,
|
||||
gssize *out_idx_first,
|
||||
gssize *out_idx_last);
|
||||
gssize nm_ptrarray_find_bsearch_range(gconstpointer *list,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data,
|
||||
gssize *out_idx_first,
|
||||
gssize *out_idx_last);
|
||||
|
||||
#define nm_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); \
|
||||
#define nm_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_ptrarray_find_bsearch((gconstpointer *) _strv, \
|
||||
_len, \
|
||||
_needle, \
|
||||
nm_strcmp_with_data, \
|
||||
NULL); \
|
||||
})
|
||||
|
||||
gssize nm_utils_array_find_binary_search(gconstpointer list,
|
||||
gsize elem_size,
|
||||
gsize len,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data);
|
||||
gssize nm_array_find_bsearch(gconstpointer list,
|
||||
gsize len,
|
||||
gsize elem_size,
|
||||
gconstpointer needle,
|
||||
GCompareDataFunc cmpfcn,
|
||||
gpointer user_data);
|
||||
|
||||
gssize nm_utils_ptrarray_find_first(gconstpointer *list, gssize len, gconstpointer needle);
|
||||
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ nm_memeq(const void *s1, const void *s2, size_t len)
|
|||
/*
|
||||
* Very similar to g_str_has_prefix() with the obvious meaning.
|
||||
* Differences:
|
||||
* 1) suffix is enforced to be a C string literal
|
||||
* 1) prefix is enforced to be a C string literal
|
||||
* (it is thus more restricted, but you'll know it at compile time).
|
||||
* 2) it accepts str==NULL
|
||||
* (it is thus more forgiving than g_str_has_prefix())
|
||||
|
|
|
|||
|
|
@ -693,12 +693,12 @@ nm_meta_setting_infos_by_name(const char *name)
|
|||
}
|
||||
|
||||
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMMetaSettingInfo, setting_name) == 0);
|
||||
idx = nm_utils_array_find_binary_search(nm_meta_setting_infos,
|
||||
sizeof(NMMetaSettingInfo),
|
||||
_NM_META_SETTING_TYPE_NUM,
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
idx = nm_array_find_bsearch(nm_meta_setting_infos,
|
||||
_NM_META_SETTING_TYPE_NUM,
|
||||
sizeof(NMMetaSettingInfo),
|
||||
&name,
|
||||
nm_strcmp_p_with_data,
|
||||
NULL);
|
||||
|
||||
return idx >= 0 ? &nm_meta_setting_infos[idx] : NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue