diff options
author | Thomas Haller <thaller@redhat.com> | 2014-07-27 23:33:16 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-08-14 01:06:25 +0200 |
commit | 2fd62b26cee68877a040d981a98b25d964923643 (patch) | |
tree | 0a4117948cb3bf252c1cf4f589bb3f1b20cc60d8 | |
parent | 4490bdbc0d33ca0202d6056b7a5410b7b53d1185 (diff) | |
download | NetworkManager-2fd62b26cee68877a040d981a98b25d964923643.tar.gz |
libnm-core: add _nm_utils_hash_values_to_slist()
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | libnm-core/nm-core-internal.h | 3 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index fdf2397d6d..1e6dd63892 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -61,4 +61,7 @@ gboolean _nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *s NM_SETTING_SECRET_FLAG_NOT_REQUIRED) +GSList * _nm_utils_hash_values_to_slist (GHashTable *hash); + + #endif diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 9c30d2e8ed..75c70491ad 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -536,6 +536,34 @@ done: return valid; } +/** + * _nm_utils_hash_values_to_slist: + * @hash: a #GHashTable + * + * Utility function to iterate over a hash table and return + * it's values as a #GSList. + * + * Returns: (element-type gpointer) (transfer container): a newly allocated #GSList + * containing the values of the hash table. The caller must free the + * returned list with g_slist_free(). The hash values are not owned + * by the returned list. + **/ +GSList * +_nm_utils_hash_values_to_slist (GHashTable *hash) +{ + GSList *list = NULL; + GHashTableIter iter; + void *value; + + g_return_val_if_fail (hash, NULL); + + g_hash_table_iter_init (&iter, hash); + while (g_hash_table_iter_next (&iter, NULL, &value)) + list = g_slist_prepend (list, value); + + return list; +} + static gboolean device_supports_ap_ciphers (guint32 dev_caps, guint32 ap_flags, |