(patch) half the number of g_strdup()s in gmarkup.c attribute parsing
- From: Michael Natterer <mitch gimp org>
- To: gtk-devel-list gnome org
- Subject: (patch) half the number of g_strdup()s in gmarkup.c attribute parsing
- Date: 17 May 2001 17:48:07 +0200
Hi all,
this is a trivial patch which saves 2 g_strdup() per attribute by simply
copying the string pointers from the GMarkupAttribute struct to the
string arrays which are passed to the application instead of duplicating
them a second time.
Ok to commit?
--Mitch
Index: gmarkup.c
===================================================================
RCS file: /cvs/gnome/glib/gmarkup.c,v
retrieving revision 1.9
diff -u -r1.9 gmarkup.c
--- gmarkup.c 2001/01/16 02:24:23 1.9
+++ gmarkup.c 2001/05/17 15:41:12
@@ -253,10 +253,10 @@
g_assert (i >= 0);
if (namesp)
- names[i] = g_strdup (attr->name);
+ names[i] = attr->name;
if (valuesp)
- values[i] = g_strdup (attr->value);
+ values[i] = attr->value;
tmp_list = g_slist_next (tmp_list);
--i;
@@ -1250,9 +1250,6 @@
/* Call user callback for element start */
start_name = current_element (context);
- /* this gratuituously copies the attr names/values
- * I guess
- */
attribute_list_to_arrays (context->attributes,
&attr_names,
&attr_values,
@@ -1267,9 +1264,12 @@
context->user_data,
&tmp_error);
- g_strfreev (attr_names);
- g_strfreev (attr_values);
-
+ /* Free only the string arrays, as we didn't g_strdup() the attribute
+ * list's strings
+ */
+ g_free (attr_names);
+ g_free (attr_values);
+
/* Go ahead and free this. */
g_slist_foreach (context->attributes, (GFunc)attribute_free,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]