From: Jim Evins Date: Sun, 10 Apr 2005 06:47:12 +0000 (+0000) Subject: 2005-04-10 Jim Evins X-Git-Tag: glabels-2_3_0~431 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cceb27eeb72f647452215fb4bf724f2946428a46;p=glabels 2005-04-10 Jim Evins * libglabels/xml-paper.c: (gl_xml_paper_parse_paper_node): * libglabels/xml-template.c: (gl_xml_template_parse_template_node), (xml_parse_label_rectangle_node), (xml_parse_label_round_node), (xml_parse_label_cd_node), (xml_parse_alias_node): * libglabels/xml.c: (gl_xml_get_prop_double), (gl_xml_get_prop_boolean), (gl_xml_get_prop_int), (gl_xml_get_prop_uint), (gl_xml_get_prop_length): * src/xml-label-04.c: (xml04_parse_media_description), (xml04_parse_text_props), (xml04_parse_barcode_props), (xml04_parse_merge_properties): * src/xml-label-191.c: (xml191_parse_object), (xml191_parse_text_props), (xml191_parse_barcode_props), (xml191_parse_merge_fields), (xml191_parse_pixdata), (xml191_parse_sheet), (xml191_parse_label), (xml191_parse_markup), (xml191_parse_alias): * src/xml-label.c: (xml_parse_object_text), (xml_parse_object_barcode), (xml_parse_merge_fields), (xml_parse_pixdata), (xml_parse_toplevel_span): Make sure to use xmlFree for anything obtained from libxml in case libxml and glib use different memory management space. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@516 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 71a4a2c3..d591ebaa 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,27 @@ +2005-04-10 Jim Evins + + * libglabels/xml-paper.c: (gl_xml_paper_parse_paper_node): + * libglabels/xml-template.c: (gl_xml_template_parse_template_node), + (xml_parse_label_rectangle_node), (xml_parse_label_round_node), + (xml_parse_label_cd_node), (xml_parse_alias_node): + * libglabels/xml.c: (gl_xml_get_prop_double), + (gl_xml_get_prop_boolean), (gl_xml_get_prop_int), + (gl_xml_get_prop_uint), (gl_xml_get_prop_length): + * src/xml-label-04.c: (xml04_parse_media_description), + (xml04_parse_text_props), (xml04_parse_barcode_props), + (xml04_parse_merge_properties): + * src/xml-label-191.c: (xml191_parse_object), + (xml191_parse_text_props), (xml191_parse_barcode_props), + (xml191_parse_merge_fields), (xml191_parse_pixdata), + (xml191_parse_sheet), (xml191_parse_label), (xml191_parse_markup), + (xml191_parse_alias): + * src/xml-label.c: (xml_parse_object_text), + (xml_parse_object_barcode), (xml_parse_merge_fields), + (xml_parse_pixdata), (xml_parse_toplevel_span): + Make sure to use xmlFree for anything obtained from libxml + in case libxml and glib use different memory management + space. + 2005-04-08 Jim Evins * src/util.h: diff --git a/glabels2/libglabels/xml-paper.c b/glabels2/libglabels/xml-paper.c index 54eaadd2..d9840970 100644 --- a/glabels2/libglabels/xml-paper.c +++ b/glabels2/libglabels/xml-paper.c @@ -149,7 +149,7 @@ glPaper * gl_xml_paper_parse_paper_node (xmlNodePtr paper_node) { glPaper *paper; - gchar *id, *name; + xmlChar *id, *name; gdouble width, height; LIBXML_TEST_VERSION; @@ -159,11 +159,11 @@ gl_xml_paper_parse_paper_node (xmlNodePtr paper_node) name = xmlGetProp (paper_node, "_name"); if (name != NULL) { - gchar *tmp = gettext (name); + xmlChar *tmp = gettext (name); if (tmp != name) { - g_free (name); - name = g_strdup (tmp); + xmlFree (name); + name = xmlStrdup (tmp); } } else { @@ -175,8 +175,8 @@ gl_xml_paper_parse_paper_node (xmlNodePtr paper_node) paper = gl_paper_new (id, name, width, height); - g_free (id); - g_free (name); + xmlFree (id); + xmlFree (name); return paper; } diff --git a/glabels2/libglabels/xml-template.c b/glabels2/libglabels/xml-template.c index 25f2ad84..f2fd80f2 100644 --- a/glabels2/libglabels/xml-template.c +++ b/glabels2/libglabels/xml-template.c @@ -183,9 +183,9 @@ gl_xml_template_parse_templates_doc (const xmlDocPtr templates_doc) glTemplate * gl_xml_template_parse_template_node (const xmlNodePtr template_node) { - gchar *name; - gchar *description; - gchar *page_size; + xmlChar *name; + xmlChar *description; + xmlChar *page_size; gdouble page_width, page_height; glPaper *paper = NULL; glTemplate *template; @@ -196,11 +196,11 @@ gl_xml_template_parse_template_node (const xmlNodePtr template_node) description = xmlGetProp (template_node, "_description"); if (description != NULL) { - gchar *tmp = gettext (description); + xmlChar *tmp = gettext (description); if (tmp != description) { - g_free (description); - description = g_strdup (tmp); + xmlFree (description); + description = xmlStrdup (tmp); } } else { @@ -221,8 +221,8 @@ gl_xml_template_parse_template_node (const xmlNodePtr template_node) g_warning (_("Unknown page size id \"%s\", trying as name"), page_size); paper = gl_paper_from_name (page_size); - g_free (page_size); - page_size = g_strdup (paper->id); + xmlFree (page_size); + page_size = xmlStrdup (paper->id); } if (paper != NULL) { page_width = paper->width; @@ -259,6 +259,10 @@ gl_xml_template_parse_template_node (const xmlNodePtr template_node) } } + xmlFree (name); + xmlFree (description); + xmlFree (page_size); + return template; } @@ -269,8 +273,8 @@ static void xml_parse_label_rectangle_node (xmlNodePtr label_node, glTemplate *template) { - gchar *id; - gchar *tmp; + xmlChar *id; + xmlChar *tmp; gdouble x_waste, y_waste; gdouble w, h, r; glTemplateLabelType *label_type; @@ -281,7 +285,7 @@ xml_parse_label_rectangle_node (xmlNodePtr label_node, if (tmp = xmlGetProp (label_node, "waste")) { /* Handle single "waste" property. */ x_waste = y_waste = gl_xml_get_prop_length (label_node, "waste", 0); - g_free (tmp); + xmlFree (tmp); } else { x_waste = gl_xml_get_prop_length (label_node, "x_waste", 0); y_waste = gl_xml_get_prop_length (label_node, "y_waste", 0); @@ -311,6 +315,7 @@ xml_parse_label_rectangle_node (xmlNodePtr label_node, } } + xmlFree (id); } /*--------------------------------------------------------------------------*/ @@ -320,7 +325,7 @@ static void xml_parse_label_round_node (xmlNodePtr label_node, glTemplate *template) { - gchar *id; + xmlChar *id; gdouble waste; gdouble r; glTemplateLabelType *label_type; @@ -350,6 +355,7 @@ xml_parse_label_round_node (xmlNodePtr label_node, } } + xmlFree (id); } /*--------------------------------------------------------------------------*/ @@ -359,7 +365,7 @@ static void xml_parse_label_cd_node (xmlNodePtr label_node, glTemplate *template) { - gchar *id; + xmlChar *id; gdouble waste; gdouble r1, r2, w, h; glTemplateLabelType *label_type; @@ -392,6 +398,7 @@ xml_parse_label_cd_node (xmlNodePtr label_node, } } + xmlFree (id); } /*--------------------------------------------------------------------------*/ @@ -518,13 +525,13 @@ static void xml_parse_alias_node (xmlNodePtr alias_node, glTemplate *template) { - gchar *name; + xmlChar *name; name = xmlGetProp (alias_node, "name"); gl_template_add_alias (template, name); - g_free (name); + xmlFree (name); } /** diff --git a/glabels2/libglabels/xml.c b/glabels2/libglabels/xml.c index d8bc8071..db51b965 100644 --- a/glabels2/libglabels/xml.c +++ b/glabels2/libglabels/xml.c @@ -90,12 +90,12 @@ gl_xml_get_prop_double (xmlNodePtr node, gdouble default_val) { gdouble val; - gchar *string; + xmlChar *string; string = xmlGetProp (node, property); if ( string != NULL ) { val = g_strtod (string, NULL); - g_free (string); + xmlFree (string); return val; } @@ -120,13 +120,13 @@ gl_xml_get_prop_boolean (xmlNodePtr node, gboolean default_val) { gboolean val; - gchar *string; + xmlChar *string; string = xmlGetProp (node, property); if ( string != NULL ) { val = !((xmlStrcasecmp (string, "false") == 0) || xmlStrEqual (string, "0"));; - g_free (string); + xmlFree (string); return val; } @@ -151,12 +151,12 @@ gl_xml_get_prop_int (xmlNodePtr node, gint default_val) { gint val; - gchar *string; + xmlChar *string; string = xmlGetProp (node, property); if ( string != NULL ) { val = strtol (string, NULL, 0); - g_free (string); + xmlFree (string); return val; } @@ -181,12 +181,12 @@ gl_xml_get_prop_uint (xmlNodePtr node, guint default_val) { guint val; - gchar *string; + xmlChar *string; string = xmlGetProp (node, property); if ( string != NULL ) { val = strtoul (string, NULL, 0); - g_free (string); + xmlFree (string); return val; } @@ -216,13 +216,14 @@ gl_xml_get_prop_length (xmlNodePtr node, gdouble default_val) { gdouble val; - gchar *string, *unit; + xmlChar *string; + xmlChar *unit; gint i; string = xmlGetProp (node, property); if ( string != NULL ) { - val = g_strtod (string, &unit); + val = g_strtod (string, (gchar **)&unit); if (unit != string) { unit = g_strchug (unit); @@ -244,7 +245,7 @@ gl_xml_get_prop_length (xmlNodePtr node, val = 0.0; } - g_free (string); + xmlFree (string); return val; } diff --git a/glabels2/src/xml-label-04.c b/glabels2/src/xml-label-04.c index 6506ec9a..9f0dbcf6 100644 --- a/glabels2/src/xml-label-04.c +++ b/glabels2/src/xml-label-04.c @@ -139,7 +139,7 @@ static gboolean xml04_parse_media_description (xmlNodePtr node, glLabel *label) { - gchar *template_name; + xmlChar *template_name; glTemplate *template; gboolean ret; @@ -160,7 +160,7 @@ xml04_parse_media_description (xmlNodePtr node, gl_label_set_template (label, template); gl_template_free (template); - g_free (template_name); + xmlFree (template_name); gl_debug (DEBUG_XML, "END"); @@ -193,17 +193,17 @@ static void xml04_parse_text_props (xmlNodePtr object_node, glLabelText *object) { - gchar *font_family; + xmlChar *font_family; gdouble font_size; GnomeFontWeight font_weight; gboolean font_italic_flag; - glColorNode *color_node; + glColorNode *color_node; GtkJustification just; xmlNodePtr line_node, text_node; - glTextNode *node_text; - GList *nodes, *lines; + glTextNode *node_text; + GList *nodes, *lines; gdouble w, h, x, y; - gchar *string; + xmlChar *string; gl_debug (DEBUG_XML, "START"); @@ -211,12 +211,12 @@ xml04_parse_text_props (xmlNodePtr object_node, font_size = gl_xml_get_prop_double (object_node, "font_size", 0); string = xmlGetProp (object_node, "font_weight"); font_weight = gl_util_string_to_weight (string); - g_free (string); + xmlFree (string); font_italic_flag = gl_xml_get_prop_boolean (object_node, "font_italic", FALSE); string = xmlGetProp (object_node, "justify"); just = gl_util_string_to_just (string); - g_free (string); + xmlFree (string); color_node = gl_color_node_new_default (); color_node->color = gl_xml_get_prop_uint (object_node, "color", 0); @@ -278,7 +278,7 @@ xml04_parse_text_props (xmlNodePtr object_node, gl_label_text_set_lines (object, lines); gl_text_node_lines_free (&lines); - g_free (font_family); + xmlFree (font_family); /* Adjust location. In 0.4.x, text was anchored at x,y */ gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); @@ -432,13 +432,12 @@ static void xml04_parse_barcode_props (xmlNodePtr node, glLabelBarcode *object) { - gchar *id; + xmlChar *id; gboolean text_flag; glColorNode *color_node; gdouble scale; xmlNodePtr child; - glTextNode *text_node; - gchar *string; + glTextNode *text_node; gl_debug (DEBUG_XML, "START"); @@ -470,7 +469,7 @@ xml04_parse_barcode_props (xmlNodePtr node, gl_color_node_free (&color_node); gl_text_node_free (&text_node); - g_free (id); + xmlFree (id); gl_debug (DEBUG_XML, "END"); } @@ -482,19 +481,19 @@ static void xml04_parse_merge_properties (xmlNodePtr node, glLabel *label) { - glMerge *merge; + glMerge *merge; xmlNodePtr child; - gchar *string; + xmlChar *string; gl_debug (DEBUG_XML, "START"); string = xmlGetProp (node, "type"); merge = gl_merge_new (string); - g_free (string); + xmlFree (string); string = xmlGetProp (node, "src"); gl_merge_set_src (merge, string); - g_free (string); + xmlFree (string); gl_label_set_merge (label, merge); diff --git a/glabels2/src/xml-label-191.c b/glabels2/src/xml-label-191.c index 4327d684..4cabb6de 100644 --- a/glabels2/src/xml-label-191.c +++ b/glabels2/src/xml-label-191.c @@ -212,7 +212,7 @@ xml191_parse_object (xmlNodePtr object_node, { glLabelObject *object; gdouble x, y; - gchar *string; + xmlChar *string; gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -233,10 +233,10 @@ xml191_parse_object (xmlNodePtr object_node, object = xml191_parse_barcode_props (object_node, label); } else { g_warning ("Unknown label object type \"%s\"", string); - g_free (string); + xmlFree (string); return; } - g_free (string); + xmlFree (string); x = gl_xml_get_prop_length (object_node, "x", 0.0); @@ -268,7 +268,7 @@ xml191_parse_text_props (xmlNodePtr object_node, GObject *object; GList *lines; gdouble w, h; - gchar *font_family; + xmlChar *font_family; gdouble font_size; GnomeFontWeight font_weight; gboolean font_italic_flag; @@ -277,7 +277,7 @@ xml191_parse_text_props (xmlNodePtr object_node, xmlNodePtr line_node, text_node; glTextNode *node_text; GList *nodes; - gchar *string; + xmlChar *string; gl_debug (DEBUG_XML, "START"); @@ -292,13 +292,13 @@ xml191_parse_text_props (xmlNodePtr object_node, string = xmlGetProp (object_node, "font_weight"); font_weight = gl_util_string_to_weight (string); - g_free (string); + xmlFree (string); font_italic_flag = gl_xml_get_prop_boolean (object_node, "font_italic", FALSE); string = xmlGetProp (object_node, "justify"); just = gl_util_string_to_just (string); - g_free (string); + xmlFree (string); color_node = gl_color_node_new_default (); color_node->color = gl_xml_get_prop_uint (object_node, "color", 0); @@ -352,7 +352,7 @@ xml191_parse_text_props (xmlNodePtr object_node, gl_color_node_free (&color_node); gl_text_node_lines_free (&lines); - g_free (font_family); + xmlFree (font_family); gl_debug (DEBUG_XML, "END"); @@ -526,9 +526,8 @@ xml191_parse_barcode_props (xmlNodePtr node, GObject *object; xmlNodePtr child; gdouble w, h; - gchar *string; glTextNode *text_node; - gchar *id; + xmlChar *id; gboolean text_flag; gboolean checksum_flag; glColorNode *color_node; @@ -570,7 +569,7 @@ xml191_parse_barcode_props (xmlNodePtr node, gl_color_node_free (&color_node); gl_text_node_free (&text_node); - g_free (id); + xmlFree (id); gl_debug (DEBUG_XML, "END"); @@ -585,18 +584,18 @@ xml191_parse_merge_fields (xmlNodePtr node, glLabel *label) { xmlNodePtr child; - gchar *string; + xmlChar *string; glMerge *merge; gl_debug (DEBUG_XML, "START"); string = xmlGetProp (node, "type"); merge = gl_merge_new (string); - g_free (string); + xmlFree (string); string = xmlGetProp (node, "src"); gl_merge_set_src (merge, string); - g_free (string); + xmlFree (string); gl_label_set_merge (label, merge); @@ -638,7 +637,7 @@ static void xml191_parse_pixdata (xmlNodePtr node, glLabel *label) { - gchar *name, *base64; + xmlChar *name, *base64; guchar *stream; guint stream_length; gboolean ret; @@ -662,8 +661,9 @@ xml191_parse_pixdata (xmlNodePtr node, gl_pixbuf_cache_add_pixbuf (pixbuf_cache, name, pixbuf); } - g_free (name); - g_free (base64); + xmlFree (name); + xmlFree (base64); + g_free (stream); g_free (pixdata); @@ -676,7 +676,7 @@ xml191_parse_pixdata (xmlNodePtr node, static glTemplate * xml191_parse_sheet (xmlNodePtr sheet_node) { - gchar *name, *description, *page_size; + xmlChar *name, *description, *page_size; gdouble page_width, page_height; glTemplate *template; xmlNodePtr node; @@ -716,7 +716,7 @@ xml191_parse_sheet (xmlNodePtr sheet_node) description = xmlGetProp (sheet_node, "_description"); if (description != NULL) { - gchar *tmp = gettext (description); + xmlChar *tmp = gettext (description); if (tmp == description) { template->description = description; @@ -745,9 +745,9 @@ xml191_parse_sheet (xmlNodePtr sheet_node) } } - g_free (name); - g_free (description); - g_free (page_size); + xmlFree (name); + xmlFree (description); + xmlFree (page_size); gl_debug (DEBUG_TEMPLATE, "END"); @@ -761,7 +761,7 @@ static void xml191_parse_label (xmlNodePtr label_node, glTemplate *template) { - gchar *style; + xmlChar *style; glTemplateLabelShape shape; gdouble w, h, r, r1, r2; glTemplateLabelType *label_type; @@ -780,7 +780,7 @@ xml191_parse_label (xmlNodePtr label_node, shape = GL_TEMPLATE_SHAPE_RECT; g_warning ("Unknown label style in template"); } - g_free (style); + xmlFree (style); switch (shape) { @@ -870,7 +870,7 @@ static void xml191_parse_markup (xmlNodePtr markup_node, glTemplateLabelType *label_type) { - gchar *type; + xmlChar *type; gdouble size; gdouble x1, y1, x2, y2; xmlNodePtr node; @@ -895,7 +895,7 @@ xml191_parse_markup (xmlNodePtr markup_node, gl_template_add_markup (label_type, gl_template_markup_line_new (x1, y1, x2, y2)); } - g_free (type); + xmlFree (type); for (node = markup_node->xmlChildrenNode; node != NULL; node = node->next) { @@ -914,13 +914,13 @@ static void xml191_parse_alias (xmlNodePtr alias_node, glTemplate *template) { - gchar *name; + xmlChar *name; gl_debug (DEBUG_TEMPLATE, "START"); name = xmlGetProp (alias_node, "name"); gl_template_add_alias (template, name); - g_free (name); + xmlFree (name); gl_debug (DEBUG_TEMPLATE, "END"); } diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index 8b0f53c2..0ef05596 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -410,7 +410,7 @@ xml_parse_object_text (xmlNodePtr node, GObject *object; gdouble x, y; gdouble w, h; - gchar *string; + xmlChar *string; GtkJustification just; gboolean auto_shrink; gdouble affine[6]; @@ -433,7 +433,7 @@ xml_parse_object_text (xmlNodePtr node, /* justify attr */ string = xmlGetProp (node, "justify"); just = gl_util_string_to_just (string); - g_free (string); + xmlFree (string); gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), just); /* auto_shrink attr */ @@ -732,9 +732,9 @@ xml_parse_object_barcode (xmlNodePtr node, GObject *object; gdouble x, y; gdouble w, h; - gchar *string; + xmlChar *string; glTextNode *text_node; - gchar *id; + xmlChar *id; gboolean text_flag; gboolean checksum_flag; glColorNode *color_node; @@ -762,13 +762,14 @@ xml_parse_object_barcode (xmlNodePtr node, format_digits = gl_xml_get_prop_uint (node, "format", 10); gl_label_barcode_set_props (GL_LABEL_BARCODE(object), id, text_flag, checksum_flag, format_digits); - g_free (id); + xmlFree (id); color_node = gl_color_node_new_default (); string = xmlGetProp (node, "color_field"); if ( string ) { color_node->field_flag = TRUE; - color_node->key = string; + color_node->key = g_strdup (string); + xmlFree (string); } else { color_node->color = gl_xml_get_prop_uint (node, "color", 0); } @@ -780,17 +781,19 @@ xml_parse_object_barcode (xmlNodePtr node, if ( string ) { text_node = g_new0 (glTextNode, 1); text_node->field_flag = FALSE; - text_node->data = string; + text_node->data = g_strdup (string); gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); gl_text_node_free (&text_node); + xmlFree (string); } else { string = xmlGetProp (node, "field"); if ( string ) { text_node = g_new0 (glTextNode, 1); text_node->field_flag = TRUE; - text_node->data = string; + text_node->data = g_strdup (string); gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); gl_text_node_free (&text_node); + xmlFree (string); } else { g_warning ("Missing Object-barcode data or field attr"); } @@ -816,18 +819,18 @@ xml_parse_merge_fields (xmlNodePtr node, glLabel *label) { xmlNodePtr child; - gchar *string; + xmlChar *string; glMerge *merge; gl_debug (DEBUG_XML, "START"); string = xmlGetProp (node, "type"); merge = gl_merge_new (string); - g_free (string); + xmlFree (string); string = xmlGetProp (node, "src"); gl_merge_set_src (merge, string); - g_free (string); + xmlFree (string); gl_label_set_merge (label, merge); @@ -869,7 +872,7 @@ static void xml_parse_pixdata (xmlNodePtr node, glLabel *label) { - gchar *name, *base64; + xmlChar *name, *base64; guchar *stream; guint stream_length; gboolean ret; @@ -893,8 +896,9 @@ xml_parse_pixdata (xmlNodePtr node, gl_pixbuf_cache_add_pixbuf (pixbuf_cache, name, pixbuf); } - g_free (name); - g_free (base64); + xmlFree (name); + xmlFree (base64); + g_free (stream); g_free (pixdata); @@ -908,13 +912,13 @@ static void xml_parse_toplevel_span (xmlNodePtr node, glLabelObject *object) { - gchar *font_family; + xmlChar *font_family; gdouble font_size; GnomeFontWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; gdouble text_line_spacing; - gchar *string; + xmlChar *string; GList *lines, *text_nodes; xmlNodePtr child; glTextNode *text_node; @@ -924,7 +928,7 @@ xml_parse_toplevel_span (xmlNodePtr node, /* Font family attr */ font_family = xmlGetProp (node, "font_family"); gl_label_object_set_font_family (object, font_family); - g_free (font_family); + xmlFree (font_family); /* Font size attr */ font_size = gl_xml_get_prop_double (node, "font_size", 0.0); @@ -933,7 +937,7 @@ xml_parse_toplevel_span (xmlNodePtr node, /* Font weight attr */ string = xmlGetProp (node, "font_weight"); font_weight = gl_util_string_to_weight (string); - g_free (string); + xmlFree (string); gl_label_object_set_font_weight (object, font_weight); /* Font italic flag attr */ @@ -945,7 +949,8 @@ xml_parse_toplevel_span (xmlNodePtr node, string = xmlGetProp (node, "color_field"); if ( string ) { color_node->field_flag = TRUE; - color_node->key = string; + color_node->key = g_strdup (string); + xmlFree (string); } else { color_node->color = gl_xml_get_prop_uint (node, "color", 0); } @@ -963,18 +968,17 @@ xml_parse_toplevel_span (xmlNodePtr node, for (child = node->xmlChildrenNode; child != NULL; child = child->next) { if (xmlNodeIsText (child)) { - gchar *data = xmlNodeGetContent (child); + xmlChar *data = xmlNodeGetContent (child); /* Hack: if the first char is LF, it's a xml formatting string */ if (data[0] != '\n') { /* Literal text */ text_node = g_new0 (glTextNode, 1); text_node->field_flag = FALSE; - text_node->data = data; + text_node->data = g_strdup (data); text_nodes = g_list_append (text_nodes, text_node); } - else - g_free (data); + xmlFree (data); } else if (xmlStrEqual (child->name, "Span")) {