[glib/wip/gcleanup: 51/71] gfileinfo: Cleanup memory
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup: 51/71] gfileinfo: Cleanup memory
- Date: Wed, 13 Nov 2013 11:38:33 +0000 (UTC)
commit d5dc17178174318bd3f1e640cf5d7826f249c9ab
Author: Stef Walter <stefw gnome org>
Date: Fri Nov 8 14:24:45 2013 +0100
gfileinfo: Cleanup memory
https://bugzilla.gnome.org/show_bug.cgi?id=711799
gio/gfileinfo.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index 81b15fb..498dcac 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -172,13 +172,36 @@ _lookup_attribute (const char *attribute)
}
static void
+cleanup_fileinfo (void)
+{
+ GHashTableIter iter;
+ NSInfo *ns_info;
+ gpointer value;
+ guint j;
+
+ g_hash_table_iter_init (&iter, ns_hash);
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ {
+ ns_info = value;
+ for (j = 0; j <= ns_info->attribute_id_counter; j++)
+ g_free (attributes[ns_info->id][j]);
+ g_free (attributes[ns_info->id]);
+ }
+
+ g_free (attributes);
+ g_hash_table_unref (ns_hash);
+ g_hash_table_unref (attribute_hash);
+}
+
+static void
ensure_attribute_hash (void)
{
if (attribute_hash != NULL)
return;
- ns_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ ns_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
attribute_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ G_CLEANUP_FUNC_IN (cleanup_fileinfo, G_CLEANUP_PHASE_LATE);
#define REGISTER_ATTRIBUTE(name) G_STMT_START{\
guint _u = _lookup_attribute (G_FILE_ATTRIBUTE_ ## name); \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]