shared: add nm_utils_named_values_from_str_dict_full() to allow different sort order (or none)
This commit is contained in:
@@ -2357,7 +2357,10 @@ nm_utils_fd_read_loop_exact (int fd, void *buf, size_t nbytes, bool do_poll)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
NMUtilsNamedValue *
|
NMUtilsNamedValue *
|
||||||
nm_utils_named_values_from_str_dict (GHashTable *hash, guint *out_len)
|
nm_utils_named_values_from_str_dict_with_sort (GHashTable *hash,
|
||||||
|
guint *out_len,
|
||||||
|
GCompareDataFunc compare_func,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
NMUtilsNamedValue *values;
|
NMUtilsNamedValue *values;
|
||||||
@@ -2380,7 +2383,8 @@ nm_utils_named_values_from_str_dict (GHashTable *hash, guint *out_len)
|
|||||||
values[i].name = NULL;
|
values[i].name = NULL;
|
||||||
values[i].value_ptr = NULL;
|
values[i].value_ptr = NULL;
|
||||||
|
|
||||||
nm_utils_named_value_list_sort (values, len, NULL, NULL);
|
if (compare_func)
|
||||||
|
nm_utils_named_value_list_sort (values, len, compare_func, user_data);
|
||||||
|
|
||||||
NM_SET_OUT (out_len, len);
|
NM_SET_OUT (out_len, len);
|
||||||
return values;
|
return values;
|
||||||
|
@@ -1207,7 +1207,18 @@ typedef struct {
|
|||||||
};
|
};
|
||||||
} NMUtilsNamedValue;
|
} NMUtilsNamedValue;
|
||||||
|
|
||||||
NMUtilsNamedValue *nm_utils_named_values_from_str_dict (GHashTable *hash, guint *out_len);
|
NMUtilsNamedValue *nm_utils_named_values_from_str_dict_with_sort (GHashTable *hash,
|
||||||
|
guint *out_len,
|
||||||
|
GCompareDataFunc compare_func,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
static inline NMUtilsNamedValue *
|
||||||
|
nm_utils_named_values_from_str_dict (GHashTable *hash, guint *out_len)
|
||||||
|
{
|
||||||
|
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMUtilsNamedValue, name) == 0);
|
||||||
|
|
||||||
|
return nm_utils_named_values_from_str_dict_with_sort (hash, out_len, nm_strcmp_p_with_data, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
gssize nm_utils_named_value_list_find (const NMUtilsNamedValue *arr,
|
gssize nm_utils_named_value_list_find (const NMUtilsNamedValue *arr,
|
||||||
gsize len,
|
gsize len,
|
||||||
|
Reference in New Issue
Block a user