mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 00:50:12 +01:00
shared: add nm_utils_hashtable_same_keys() util
This commit is contained in:
parent
fcaf7994f2
commit
ec707f56c1
2 changed files with 32 additions and 0 deletions
|
|
@ -2282,6 +2282,35 @@ nm_utils_hash_keys_to_array (GHashTable *hash,
|
|||
return keys;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_utils_hashtable_same_keys (const GHashTable *a,
|
||||
const GHashTable *b)
|
||||
{
|
||||
GHashTableIter h;
|
||||
const char *k;
|
||||
|
||||
if (a == b)
|
||||
return TRUE;
|
||||
if (!a || !b)
|
||||
return FALSE;
|
||||
if (g_hash_table_size ((GHashTable *) a) != g_hash_table_size ((GHashTable *) b))
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_iter_init (&h, (GHashTable *) a);
|
||||
while (g_hash_table_iter_next (&h, (gpointer) &k, NULL)) {
|
||||
if (!g_hash_table_contains ((GHashTable *) b, k))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS > 5
|
||||
g_hash_table_iter_init (&h, (GHashTable *) b);
|
||||
while (g_hash_table_iter_next (&h, (gpointer) &k, NULL))
|
||||
nm_assert (g_hash_table_contains ((GHashTable *) a, k));
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char **
|
||||
nm_utils_strv_make_deep_copied (const char **strv)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -966,6 +966,9 @@ nm_utils_strdict_get_keys (const GHashTable *hash,
|
|||
out_length);
|
||||
}
|
||||
|
||||
gboolean nm_utils_hashtable_same_keys (const GHashTable *a,
|
||||
const GHashTable *b);
|
||||
|
||||
char **nm_utils_strv_make_deep_copied (const char **strv);
|
||||
|
||||
char **nm_utils_strv_make_deep_copied_n (const char **strv, gsize len);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue