diff options
author | Thomas Haller <thaller@redhat.com> | 2013-10-18 16:07:26 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2013-10-22 19:53:57 +0200 |
commit | 3eb1d5e9024108fe656476dc5a11fefd194d0c54 (patch) | |
tree | e59c0a5cef44de57babcf79784320092691a467e /libnm-util/nm-param-spec-specialized.c | |
parent | 1c93b24829d61e58624bf2dd20ebb34b3fceabea (diff) | |
download | NetworkManager-3eb1d5e9024108fe656476dc5a11fefd194d0c54.tar.gz |
core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.
The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'libnm-util/nm-param-spec-specialized.c')
-rw-r--r-- | libnm-util/nm-param-spec-specialized.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libnm-util/nm-param-spec-specialized.c b/libnm-util/nm-param-spec-specialized.c index 9a671a2e87..9f64df335a 100644 --- a/libnm-util/nm-param-spec-specialized.c +++ b/libnm-util/nm-param-spec-specialized.c @@ -291,10 +291,8 @@ _gvalues_compare_collection (const GValue *value1, const GValue *value2) ret = _gvalues_compare ((GValue *) iter1->data, (GValue *) iter2->data); } - g_slist_foreach (list1, (GFunc) _gvalue_destroy, NULL); - g_slist_free (list1); - g_slist_foreach (list2, (GFunc) _gvalue_destroy, NULL); - g_slist_free (list2); + g_slist_free_full (list1, _gvalue_destroy); + g_slist_free_full (list2, _gvalue_destroy); } return ret; |