summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Nazar <nazard@nazar.ca>2021-05-12 17:43:46 -0400
committerDoug Nazar <nazard@nazar.ca>2021-05-12 18:59:16 -0400
commit60856d5a6fdd8a7b9cb1492197d3aa201a43828d (patch)
tree9e4bc724cdcec1a52a625df9bbcf1cd06071fa8b
parent294ad1d56406492ff17e447ceba0d444565dad9b (diff)
xml-formatter: Write xml directly to file
Skip allocation of temp buffer (which was undersized). Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/250>
-rw-r--r--ges/ges-xml-formatter.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/ges/ges-xml-formatter.c b/ges/ges-xml-formatter.c
index 409c5542..0747ccf5 100644
--- a/ges/ges-xml-formatter.c
+++ b/ges/ges-xml-formatter.c
@@ -953,7 +953,6 @@ _save_subproject_data (GESXmlFormatter * self, SubprojectData * subproj_data,
gint line = 1, i;
gboolean res = FALSE;
gsize start = 0, end = 0;
- gchar *subproject_content = NULL;
gchar *xml = GES_BASE_XML_FORMATTER (self)->xmlcontent;
for (i = 0; xml[i] != '\0'; i++) {
@@ -973,17 +972,12 @@ _save_subproject_data (GESXmlFormatter * self, SubprojectData * subproj_data,
g_assert (start && end);
size = (end - start);
- subproject_content = g_malloc (sizeof (gchar) * size);
- memcpy (subproject_content, &xml[start], end - start);
- subproject_content[end - start] = '\0';
GST_INFO_OBJECT (self, "Saving subproject %s from %d:%d(%" G_GSIZE_FORMAT
") to %d:%d(%" G_GSIZE_FORMAT ")",
subproj_data->id, subproj_data->start_line, subproj_data->start_char,
start, subproject_end_line, subproject_end_char, end);
- res = g_file_set_contents (subproj_data->filename, subproject_content, -1,
- error);
- g_free (subproject_content);
+ res = g_file_set_contents (subproj_data->filename, &xml[start], size, error);
return res;
}