[tracker/cuesheets] tracker-extract: Use g_strchug() functionality to avoid allocating memory
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/cuesheets] tracker-extract: Use g_strchug() functionality to avoid allocating memory
- Date: Thu, 29 Sep 2011 16:44:28 +0000 (UTC)
commit ce18e403f5d58b2af6303e376b8ebf3867aaafcd
Author: Martyn Russell <martyn lanedo com>
Date: Thu Sep 29 17:41:31 2011 +0100
tracker-extract: Use g_strchug() functionality to avoid allocating memory
Previously the work from Sam just returned buffer and the returned string
required a +9 to get past the cuesheet=, however, I thought it better to
just move the memory in a similar way to g_strchug() so we don't allocated any
memory and the returned value can be used straight away.
src/tracker-extract/tracker-extract-gstreamer.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index bb29738..9091939 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -383,16 +383,21 @@ get_embedded_cue_sheet_data (GstTagList *tag_list)
gst_tag_list_get_string_index (tag_list, GST_TAG_EXTENDED_COMMENT, i, &buffer);
if (g_ascii_strncasecmp (buffer, "cuesheet=", 9) == 0) {
- gchar *result;
-
- result = g_strdup (buffer + 9);
- g_free (buffer);
+ /* Use same functionality as g_strchug() here
+ * for cuesheet, to avoid allocating new
+ * memory but also to return the string and
+ * not have to jump past cuesheet= on the
+ * returned value.
+ */
+ g_memmove (buffer, buffer + 9, strlen ((gchar *) buffer + 9) + 1);
- return result;
+ return buffer;
}
g_free (buffer);
}
+
+ return NULL;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]