mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 16:30:23 +01:00
libnm-util: convert nm_connection_duplicate() to GHashTableIter
This commit is contained in:
parent
7a7ce3b8e2
commit
a8d33c7e2c
1 changed files with 6 additions and 7 deletions
|
|
@ -1150,12 +1150,6 @@ nm_connection_new_from_hash (GHashTable *hash, GError **error)
|
|||
return connection;
|
||||
}
|
||||
|
||||
static void
|
||||
duplicate_cb (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
nm_connection_add_setting (NM_CONNECTION (user_data), nm_setting_duplicate (NM_SETTING (value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_duplicate:
|
||||
* @connection: the #NMConnection to duplicate
|
||||
|
|
@ -1169,12 +1163,17 @@ NMConnection *
|
|||
nm_connection_duplicate (NMConnection *connection)
|
||||
{
|
||||
NMConnection *dup;
|
||||
GHashTableIter iter;
|
||||
NMSetting *setting;
|
||||
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
||||
|
||||
dup = nm_connection_new ();
|
||||
nm_connection_set_path (dup, nm_connection_get_path (connection));
|
||||
g_hash_table_foreach (NM_CONNECTION_GET_PRIVATE (connection)->settings, duplicate_cb, dup);
|
||||
|
||||
g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (connection)->settings);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &setting))
|
||||
nm_connection_add_setting (dup, nm_setting_duplicate (setting));
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue