[tracker] Plug several memory leaks.



commit 0f10572871f0179bc9c82fa17a8fe0957f2a9b57
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/trackerd/tracker-daemon.c       |    3 +--
 src/trackerd/tracker-push.c         |    9 ++++-----
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/libtracker-db/tracker-db-dbus.c b/src/libtracker-db/tracker-db-dbus.c
index c4323d4..ac1ec61 100644
--- a/src/libtracker-db/tracker-db-dbus.c
+++ b/src/libtracker-db/tracker-db-dbus.c
@@ -362,22 +362,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)) {
@@ -388,16 +387,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/trackerd/tracker-daemon.c b/src/trackerd/tracker-daemon.c
index 2c69881..693efb6 100644
--- a/src/trackerd/tracker-daemon.c
+++ b/src/trackerd/tracker-daemon.c
@@ -418,8 +418,7 @@ stats_cache_get_latest (void)
 	}
 
 	g_ptr_array_foreach (stats, stats_cache_filter_dups_func, values);
-
-	g_ptr_array_free (stats, TRUE);
+	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]