mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-15 10:20:30 +01:00
shared: add nm_utils_strdict_clone() helper
This commit is contained in:
parent
571aeec933
commit
0cf4250021
2 changed files with 20 additions and 0 deletions
|
|
@ -434,6 +434,24 @@ nm_g_variant_singleton_u_0(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
GHashTable *
|
||||
nm_utils_strdict_clone(GHashTable *src)
|
||||
{
|
||||
GHashTable * dst;
|
||||
GHashTableIter iter;
|
||||
const char * key;
|
||||
const char * val;
|
||||
|
||||
if (!src)
|
||||
return NULL;
|
||||
|
||||
dst = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free);
|
||||
g_hash_table_iter_init(&iter, src);
|
||||
while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val))
|
||||
g_hash_table_insert(dst, g_strdup(key), g_strdup(val));
|
||||
return dst;
|
||||
}
|
||||
|
||||
/* Convert a hash table with "char *" keys and values to an "a{ss}" GVariant.
|
||||
* The keys will be sorted asciibetically.
|
||||
* Returns a floating reference.
|
||||
|
|
|
|||
|
|
@ -320,6 +320,8 @@ gboolean nm_utils_gbytes_equal_mem(GBytes *bytes, gconstpointer mem_data, gsize
|
|||
|
||||
GVariant *nm_utils_gbytes_to_variant_ay(GBytes *bytes);
|
||||
|
||||
GHashTable *nm_utils_strdict_clone(GHashTable *src);
|
||||
|
||||
GVariant *nm_utils_strdict_to_variant_ass(GHashTable *strdict);
|
||||
GVariant *nm_utils_strdict_to_variant_asv(GHashTable *strdict);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue