[tracker/tracker-0.6] Plug several memory leaks.



commit 5ea6026ff809077e78f600fa800e25d781bab2b8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Apr 27 16:43:21 2009 +0200

    Plug several memory leaks.
---
 src/libtracker-db/tracker-db-dbus.c  |   12 +++++++++---
 src/libtracker-db/tracker-db-index.c |    2 ++
 src/trackerd/tracker-daemon.c        |    4 ++--
 src/trackerd/tracker-push.c          |    9 ++++-----
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/libtracker-db/tracker-db-dbus.c b/src/libtracker-db/tracker-db-dbus.c
index 666fa3e..939cbc5 100644
--- a/src/libtracker-db/tracker-db-dbus.c
+++ b/src/libtracker-db/tracker-db-dbus.c
@@ -360,22 +360,21 @@ tracker_dbus_query_result_to_hash_table (TrackerDBResultSet *result_set)
 	}
 
 	while (valid) {
-		GValue	 transform = { 0, };
 		GValue	*values;
 		gchar  **p;
 		gint	 i = 0;
 		gchar	*key;
 		GSList	*list = NULL;
 
-		g_value_init (&transform, G_TYPE_STRING);
-
 		tracker_db_result_set_get (result_set, 0, &key, -1);
 		values = tracker_dbus_gvalue_slice_new (G_TYPE_STRV);
 
 		for (i = 1; i < field_count; i++) {
+			GValue  transform = { 0, };
 			GValue	value = { 0, };
 			gchar  *str;
 
+			g_value_init (&transform, G_TYPE_STRING);
 			_tracker_db_result_set_get_value (result_set, i, &value);
 
 			if (g_value_transform (&value, &transform)) {
@@ -386,16 +385,23 @@ tracker_dbus_query_result_to_hash_table (TrackerDBResultSet *result_set)
 					g_free (str);
 					str = g_strdup ("");
 				}
+
+				g_value_unset (&transform);
 			} else {
 				str = g_strdup ("");
 			}
 
 			list = g_slist_prepend (list, (gchar*) str);
+
+			g_value_unset (&value);
 		}
 
 		list = g_slist_reverse (list);
 		p = tracker_dbus_slist_to_strv (list);
+
+		g_slist_foreach (list, (GFunc)g_free, NULL);
 		g_slist_free (list);
+
 		g_value_take_boxed (values, p);
 		g_hash_table_insert (hash_table, key, values);
 
diff --git a/src/libtracker-db/tracker-db-index.c b/src/libtracker-db/tracker-db-index.c
index d669b1d..4df697e 100644
--- a/src/libtracker-db/tracker-db-index.c
+++ b/src/libtracker-db/tracker-db-index.c
@@ -215,6 +215,8 @@ tracker_db_index_finalize (GObject *object)
 		tracker_db_index_open (indez);
 		tracker_db_index_flush_sync (indez);
 		tracker_db_index_close (indez);
+	} else  {
+		tracker_db_index_close (indez);
 	}
 
 	if (priv->idle_flush_id) {
diff --git a/src/trackerd/tracker-daemon.c b/src/trackerd/tracker-daemon.c
index dbbfec0..3793952 100644
--- a/src/trackerd/tracker-daemon.c
+++ b/src/trackerd/tracker-daemon.c
@@ -482,8 +482,8 @@ stats_cache_get_latest (void)
 		g_ptr_array_foreach (stats, stats_cache_filter_dups_func, values);
 		g_ptr_array_foreach (parent_stats, stats_cache_filter_dups_func, values);
 
-		g_ptr_array_free (parent_stats, TRUE);
-		g_ptr_array_free (stats, TRUE);
+		tracker_dbus_results_ptr_array_free (&parent_stats);
+		tracker_dbus_results_ptr_array_free (&stats);
 	}
 
 	return values;
diff --git a/src/trackerd/tracker-push.c b/src/trackerd/tracker-push.c
index 754fff0..a7e90f4 100644
--- a/src/trackerd/tracker-push.c
+++ b/src/trackerd/tracker-push.c
@@ -52,13 +52,10 @@ static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
 static void
 load_modules (PushSupportPrivate *private)
 {
-	GError *error = NULL;
-	GDir *dir = g_dir_open (PUSH_MODULES_DIR, 0, &error);
+	GDir *dir = g_dir_open (PUSH_MODULES_DIR, 0, NULL);
 	const gchar *name;
 
-
-	if (error) {
-		g_error_free (error);
+	if (!dir) {
 		return;
 	}
 
@@ -92,6 +89,8 @@ load_modules (PushSupportPrivate *private)
 			g_free (path);
 		}
 	}
+
+	g_dir_close (dir);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]