From 05f143a808c747931ff3f6f483f3c760c2bdce04 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 18 May 2001 12:38:32 +0000 Subject: [PATCH] don't g_strdup()/g_free() all parsed attributes and their values twice but 2001-05-18 Michael Natterer * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and their values twice but simply copy the string pointers from the GMarkupAttribute struct to the string arrays before passing them to start_element(). --- ChangeLog | 7 +++++++ ChangeLog.pre-2-0 | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ ChangeLog.pre-2-2 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ glib/gmarkup.c | 16 ++++++++-------- gmarkup.c | 16 ++++++++-------- 10 files changed, 72 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 805621a..637a1b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 805621a..637a1b7 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2001-05-18 Michael Natterer + + * gmarkup.c: don't g_strdup()/g_free() all parsed attributes and + their values twice but simply copy the string pointers from the + GMarkupAttribute struct to the string arrays before passing them + to start_element(). + 2001-05-18 Sebastian Wilhelmi * gthread.c, gthread.h: Renamed g_thread_create to diff --git a/glib/gmarkup.c b/glib/gmarkup.c index 6fd5a10..87d6091 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -253,10 +253,10 @@ attribute_list_to_arrays (GSList *attributes, 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 @@ g_markup_parse_context_parse (GMarkupParseContext *context, /* 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 @@ g_markup_parse_context_parse (GMarkupParseContext *context, 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); diff --git a/gmarkup.c b/gmarkup.c index 6fd5a10..87d6091 100644 --- a/gmarkup.c +++ b/gmarkup.c @@ -253,10 +253,10 @@ attribute_list_to_arrays (GSList *attributes, 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 @@ g_markup_parse_context_parse (GMarkupParseContext *context, /* 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 @@ g_markup_parse_context_parse (GMarkupParseContext *context, 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); -- 2.7.4