[tracker/libtracker-sparql-porting: 35/45] libtracker-miner, miners/rss, plugins/evolution: Fixed memory leaks for cursors



commit 035af2745126ec80109457a7ab73791c9e2badf1
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Aug 2 15:17:42 2010 +0200

    libtracker-miner, miners/rss, plugins/evolution: Fixed memory leaks for cursors

 src/libtracker-miner/tracker-miner-fs.c          |   19 ++++++++++-
 src/miners/rss/tracker-miner-rss.c               |   37 ++++++++++++++--------
 src/plugins/evolution/tracker-evolution-plugin.c |    6 ++--
 3 files changed, 45 insertions(+), 17 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 40ecb52..3b62cb2 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1095,11 +1095,16 @@ item_query_exists_cb (GObject      *object,
 	if (error) {
 		g_critical ("Could not execute sparql query: %s", error->message);
 		g_error_free (error);
+		if (cursor) {
+			g_object_unref (cursor);
+		}
 		return;
 	}
 
-	if (!tracker_sparql_cursor_next (cursor, NULL, NULL))
+	if (!tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+		g_object_unref (cursor);
 		return;
+	}
 
 	n_results = 1;
 	data->iri = g_strdup (tracker_sparql_cursor_get_string (cursor, 0, NULL));
@@ -1122,6 +1127,8 @@ item_query_exists_cb (GObject      *object,
 		            tracker_sparql_cursor_get_string (cursor, 0, NULL),
 		            data->get_mime ? tracker_sparql_cursor_get_string (cursor, 1, NULL) : "unneeded");
 	}
+
+	g_object_unref (cursor);
 }
 
 static gboolean
@@ -1193,6 +1200,9 @@ cache_query_cb (GObject	     *object,
 	if (G_UNLIKELY (error)) {
 		g_critical ("Could not execute cache query: %s", error->message);
 		g_error_free (error);
+		if (cursor) {
+			g_object_unref (cursor);
+		}
 		return;
 	}
 
@@ -1205,6 +1215,8 @@ cache_query_cb (GObject	     *object,
 		                     file,
 		                     g_strdup (tracker_sparql_cursor_get_string (cursor, 1, NULL)));
 	}
+
+	g_object_unref (cursor);
 }
 
 static gboolean
@@ -1746,6 +1758,9 @@ item_update_children_uri_cb (GObject      *object,
 	if (error) {
 		g_critical ("Could not query children: %s", error->message);
 		g_error_free (error);
+		if (cursor) {
+			g_object_unref (cursor);
+		}
 	} else {
 		while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
 			const gchar *child_source_uri, *child_mime, *child_urn;
@@ -1784,6 +1799,8 @@ item_update_children_uri_cb (GObject      *object,
 		}
 	}
 
+	g_object_unref (cursor);
+
 	g_main_loop_quit (data->main_loop);
 }
 
diff --git a/src/miners/rss/tracker-miner-rss.c b/src/miners/rss/tracker-miner-rss.c
index e100f94..390a237 100644
--- a/src/miners/rss/tracker-miner-rss.c
+++ b/src/miners/rss/tracker-miner-rss.c
@@ -303,16 +303,21 @@ item_verify_reply_cb (GObject      *source_object,
 	if (error != NULL) {
 		g_message ("Could not verify feed existance, %s", error->message);
 		g_error_free (error);
+		if (cursor) {
+			g_object_unref (cursor);
+		}
 		return;
 	}
 
-        if (!tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+	if (!tracker_sparql_cursor_next (cursor, NULL, NULL)) {
 		g_message ("No data in query response??");
-                return;
-        }
+		g_object_unref (cursor);
+		return;
+	}
 
 	str = tracker_sparql_cursor_get_string (cursor, 0, NULL);
 	if (g_strcmp0 (str, "1") == 0) {
+		g_object_unref (cursor);
 		return;
 	}
 
@@ -408,6 +413,7 @@ item_verify_reply_cb (GObject      *source_object,
                                                 verify_item_insertion,
                                                 NULL);
 
+	g_object_unref (cursor);
 	g_object_unref (sparql);
 }
 
@@ -486,12 +492,15 @@ feeds_retrieve_cb (GObject      *source_object,
 	FeedChannel *chan;
 
 	cursor = tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (source_object),
-                                                         res,
-                                                         &error);
+	                                                     res,
+	                                                     &error);
 
 	if (error != NULL) {
 		g_message ("Could not retrieve feeds, %s", error->message);
 		g_error_free (error);
+		if (cursor) {
+			g_object_unref (cursor);
+		}
 		return;
 	}
 
@@ -499,15 +508,15 @@ feeds_retrieve_cb (GObject      *source_object,
 
 	g_message ("Found feeds");
 
-        while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
-                const gchar *source;
-                const gchar *interval;
-                const gchar *subject;
-                gint mins;
+	while (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
+		const gchar *source;
+		const gchar *interval;
+		const gchar *subject;
+		gint mins;
 
-                source = tracker_sparql_cursor_get_string (cursor, 0, NULL);
-                interval = tracker_sparql_cursor_get_string (cursor, 1, NULL);
-                subject = tracker_sparql_cursor_get_string (cursor, 2, NULL);
+		source = tracker_sparql_cursor_get_string (cursor, 0, NULL);
+		interval = tracker_sparql_cursor_get_string (cursor, 1, NULL);
+		subject = tracker_sparql_cursor_get_string (cursor, 2, NULL);
 
 		chan = feed_channel_new ();
 		g_object_set_data_full (G_OBJECT (chan),
@@ -530,6 +539,8 @@ feeds_retrieve_cb (GObject      *source_object,
 
 	priv = TRACKER_MINER_RSS_GET_PRIVATE (user_data);
 	feeds_pool_listen (priv->pool, channels);
+
+	g_object_unref (cursor);
 }
 
 static void
diff --git a/src/plugins/evolution/tracker-evolution-plugin.c b/src/plugins/evolution/tracker-evolution-plugin.c
index 61b4b31..dbf3f31 100644
--- a/src/plugins/evolution/tracker-evolution-plugin.c
+++ b/src/plugins/evolution/tracker-evolution-plugin.c
@@ -1748,7 +1748,7 @@ on_register_client_qry (GObject *source_object,
 		g_error_free (error);
 		g_slice_free (ClientRegistry, info);
 		if (cursor) {
-			//g_object_unref (cursor);
+			g_object_unref (cursor);
 		}
 		return;
 	}
@@ -1771,7 +1771,7 @@ on_register_client_qry (GObject *source_object,
 			if (new_error) {
 				g_warning ("%s", new_error->message);
 				g_error_free (error);
-				//g_object_unref (cursor);
+				g_object_unref (cursor);
 				return;
 			}
 
@@ -1781,7 +1781,7 @@ on_register_client_qry (GObject *source_object,
 
 	register_client_second_half (info);
 
-	//g_object_unref (cursor);
+	g_object_unref (cursor);
 }
 
 static void



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