[tracker/journal] libtracker-data: Avoid duplicating subject string in memory
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/journal] libtracker-data: Avoid duplicating subject string in memory
- Date: Fri, 12 Mar 2010 10:50:18 +0000 (UTC)
commit 8c2589100ccf6ba67ad3886535db0a4a3088b206
Author: Jürg Billeter <j bitron ch>
Date: Fri Mar 12 11:49:47 2010 +0100
libtracker-data: Avoid duplicating subject string in memory
src/libtracker-data/tracker-data-update.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 6313d52..1ef0342 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -68,7 +68,7 @@ struct _TrackerDataUpdateBuffer {
};
struct _TrackerDataUpdateBufferResource {
- gchar *subject;
+ const gchar *subject;
gchar *new_subject;
gint id;
gboolean create;
@@ -708,7 +708,6 @@ static void resource_buffer_free (TrackerDataUpdateBufferResource *resource)
g_hash_table_unref (resource->predicates);
g_hash_table_unref (resource->tables);
- g_free (resource->subject);
resource->subject = NULL;
g_ptr_array_free (resource->types, TRUE);
@@ -1448,11 +1447,13 @@ resource_buffer_switch (const gchar *graph,
if (resource_buffer == NULL) {
GValue gvalue = { 0 };
+ gchar *subject_dup = NULL;
/* subject not yet in cache, retrieve or create ID */
resource_buffer = g_slice_new0 (TrackerDataUpdateBufferResource);
if (subject != NULL) {
- resource_buffer->subject = g_strdup (subject);
+ subject_dup = g_strdup (subject);
+ resource_buffer->subject = subject_dup;
}
if (subject_id > 0) {
resource_buffer->id = subject_id;
@@ -1471,7 +1472,7 @@ resource_buffer_switch (const gchar *graph,
if (in_journal_replay) {
g_hash_table_insert (update_buffer.resources_by_id, GINT_TO_POINTER (subject_id), resource_buffer);
} else {
- g_hash_table_insert (update_buffer.resources, g_strdup (subject), resource_buffer);
+ g_hash_table_insert (update_buffer.resources, subject_dup, resource_buffer);
if (graph != NULL) {
graph_id = ensure_resource_id (graph, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]