diff options
author | Stefano Karapetsas <[email protected]> | 2013-10-06 18:12:22 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-10-06 18:13:34 +0200 |
commit | bd7e0b8c49a423789495678fb65b519c707feed4 (patch) | |
tree | 45295793d3a0f0025cee350b7ac7935cdf5fa9ca | |
parent | 73cc7e98f61b2d5f327f26a2e6f4e5004347bf01 (diff) | |
download | caja-bd7e0b8c49a423789495678fb65b519c707feed4.tar.bz2 caja-bd7e0b8c49a423789495678fb65b519c707feed4.tar.xz |
Properly free GHashTable in properties window
Closes #178
https://github.com/mate-desktop/mate-file-manager/issues/178
I had to recover two functions previously removed in eel-glib-extensions.
-rw-r--r-- | eel/eel-glib-extensions.c | 28 | ||||
-rw-r--r-- | eel/eel-glib-extensions.h | 6 | ||||
-rw-r--r-- | src/file-manager/fm-properties-window.c | 2 |
3 files changed, 35 insertions, 1 deletions
diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index ee108050..96eeb354 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -378,6 +378,34 @@ eel_g_str_list_index (GList *str_list, } /** + * eel_g_list_free_deep_custom + * + * Frees the elements of a list and then the list, using a custom free function. + * + * @list: List of elements that can be freed with the provided free function. + * @element_free_func: function to call with the data pointer and user_data to free it. + * @user_data: User data to pass to element_free_func + **/ +void +eel_g_list_free_deep_custom (GList *list, GFunc element_free_func, gpointer user_data) +{ + g_list_foreach (list, element_free_func, user_data); + g_list_free (list); +} + +/** + * eel_g_list_free_deep + * + * Frees the elements of a list and then the list. + * @list: List of elements that can be freed with g_free. + **/ +void +eel_g_list_free_deep (GList *list) +{ + eel_g_list_free_deep_custom (list, (GFunc) g_free, NULL); +} + +/** * eel_g_strv_find * * Get index of string in array of strings. diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index 907a1ec9..9c62c57f 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -54,6 +54,12 @@ GList * eel_g_list_partition (GList * gpointer user_data, GList **removed); +/* List functions for lists of g_free'able objects. */ +void eel_g_list_free_deep (GList *list); +void eel_g_list_free_deep_custom (GList *list, + GFunc element_free_func, + gpointer user_data); + /* List functions for lists of C strings. */ gboolean eel_g_str_list_equal (GList *str_list_a, GList *str_list_b); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index a62fbec5..46af0109 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -3423,7 +3423,7 @@ get_initial_emblems (GList *files) ret = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, - (GDestroyNotify) g_free); + (GDestroyNotify) eel_g_list_free_deep); for (l = files; l != NULL; l = l->next) { CajaFile *file; |