[tracker] libtracker-data: No strdup for strings that aren't freed



commit 655b41140919337fdf1401161c834b91b6130752
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Mar 11 14:24:50 2010 +0100

    libtracker-data: No strdup for strings that aren't freed

 src/libtracker-data/tracker-data-update.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index bb7da8b..51a57fd 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -80,7 +80,7 @@ struct _TrackerDataUpdateBufferResource {
 };
 
 struct _TrackerDataUpdateBufferProperty {
-	gchar *name;
+	const gchar *name;
 	GValue value;
 	gint graph;
 	gboolean fts : 1;
@@ -281,7 +281,6 @@ cache_table_free (TrackerDataUpdateBufferTable *table)
 
 	for (i = 0; i < table->properties->len; i++) {
 		property = &g_array_index (table->properties, TrackerDataUpdateBufferProperty, i);
-		g_free (property->name);
 		g_value_unset (&property->value);
 	}
 
@@ -327,7 +326,10 @@ cache_insert_value (const gchar            *table_name,
 	TrackerDataUpdateBufferTable    *table;
 	TrackerDataUpdateBufferProperty  property;
 
-	property.name = g_strdup (field_name);
+	/* No need to strdup here, the incoming string is either always static, or
+	 * long-standing as tracker_property_get_name return value. */
+	property.name = field_name;
+
 	property.value = *value;
 	property.graph = graph;
 	property.fts = fts;



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