[tracker/harmattan-pre-signal-updates: 1344/1380] libtracker-common: Avoid a malloc



commit 1e7bbe2b826fdcf6efbb97ea6863ba5f92d7e840
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Sep 16 10:23:34 2010 +0200

    libtracker-common: Avoid a malloc

 src/libtracker-common/tracker-dbus.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index fb129fe..b20fe2f 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -710,10 +710,8 @@ static GStrv
 dbus_send_and_splice_get_variable_names (DBusMessage *message,
                                          gboolean     copy_strings)
 {
-	GStrv v_names;
 	GPtrArray *found;
 	DBusMessageIter iter, arr;
-	guint i;
 
 	dbus_message_iter_init (message, &iter);
 	dbus_message_iter_recurse (&iter, &arr);
@@ -723,20 +721,14 @@ dbus_send_and_splice_get_variable_names (DBusMessage *message,
 	while (dbus_message_iter_get_arg_type (&arr) != DBUS_TYPE_INVALID) {
 		gchar *str;
 
-		/* Make a copy here, we wont own when returning */
 		dbus_message_iter_get_basic (&arr, &str);
 		g_ptr_array_add (found, copy_strings ? g_strdup (str) : str);
 		dbus_message_iter_next (&arr);
 	}
 
-	v_names = g_new0 (gchar *, found->len + 1);
-	for (i = 0; i < found->len; i++) {
-		v_names[i] = g_ptr_array_index (found, i);
-	}
-
-	g_ptr_array_free (found, TRUE);
+	g_ptr_array_add (found, NULL);
 
-	return v_names;
+	return g_ptr_array_free (found, FALSE);
 }
 
 /*



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