* 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
+2005-04-10 Jim Evins <evins@snaught.com>
+
+ * 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 <evins@snaught.com>
* src/util.h:
gl_xml_paper_parse_paper_node (xmlNodePtr paper_node)
{
glPaper *paper;
- gchar *id, *name;
+ xmlChar *id, *name;
gdouble width, height;
LIBXML_TEST_VERSION;
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 {
paper = gl_paper_new (id, name, width, height);
- g_free (id);
- g_free (name);
+ xmlFree (id);
+ xmlFree (name);
return paper;
}
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;
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 {
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;
}
}
+ xmlFree (name);
+ xmlFree (description);
+ xmlFree (page_size);
+
return template;
}
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;
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);
}
}
+ xmlFree (id);
}
/*--------------------------------------------------------------------------*/
xml_parse_label_round_node (xmlNodePtr label_node,
glTemplate *template)
{
- gchar *id;
+ xmlChar *id;
gdouble waste;
gdouble r;
glTemplateLabelType *label_type;
}
}
+ xmlFree (id);
}
/*--------------------------------------------------------------------------*/
xml_parse_label_cd_node (xmlNodePtr label_node,
glTemplate *template)
{
- gchar *id;
+ xmlChar *id;
gdouble waste;
gdouble r1, r2, w, h;
glTemplateLabelType *label_type;
}
}
+ xmlFree (id);
}
/*--------------------------------------------------------------------------*/
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);
}
/**
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;
}
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;
}
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;
}
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;
}
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);
val = 0.0;
}
- g_free (string);
+ xmlFree (string);
return val;
}
xml04_parse_media_description (xmlNodePtr node,
glLabel *label)
{
- gchar *template_name;
+ xmlChar *template_name;
glTemplate *template;
gboolean ret;
gl_label_set_template (label, template);
gl_template_free (template);
- g_free (template_name);
+ xmlFree (template_name);
gl_debug (DEBUG_XML, "END");
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");
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);
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);
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");
gl_color_node_free (&color_node);
gl_text_node_free (&text_node);
- g_free (id);
+ xmlFree (id);
gl_debug (DEBUG_XML, "END");
}
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);
{
glLabelObject *object;
gdouble x, y;
- gchar *string;
+ xmlChar *string;
gdouble affine[6];
gl_debug (DEBUG_XML, "START");
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);
GObject *object;
GList *lines;
gdouble w, h;
- gchar *font_family;
+ xmlChar *font_family;
gdouble font_size;
GnomeFontWeight font_weight;
gboolean font_italic_flag;
xmlNodePtr line_node, text_node;
glTextNode *node_text;
GList *nodes;
- gchar *string;
+ xmlChar *string;
gl_debug (DEBUG_XML, "START");
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);
gl_color_node_free (&color_node);
gl_text_node_lines_free (&lines);
- g_free (font_family);
+ xmlFree (font_family);
gl_debug (DEBUG_XML, "END");
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;
gl_color_node_free (&color_node);
gl_text_node_free (&text_node);
- g_free (id);
+ xmlFree (id);
gl_debug (DEBUG_XML, "END");
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);
xml191_parse_pixdata (xmlNodePtr node,
glLabel *label)
{
- gchar *name, *base64;
+ xmlChar *name, *base64;
guchar *stream;
guint stream_length;
gboolean ret;
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);
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;
description = xmlGetProp (sheet_node, "_description");
if (description != NULL) {
- gchar *tmp = gettext (description);
+ xmlChar *tmp = gettext (description);
if (tmp == description) {
template->description = description;
}
}
- g_free (name);
- g_free (description);
- g_free (page_size);
+ xmlFree (name);
+ xmlFree (description);
+ xmlFree (page_size);
gl_debug (DEBUG_TEMPLATE, "END");
xml191_parse_label (xmlNodePtr label_node,
glTemplate *template)
{
- gchar *style;
+ xmlChar *style;
glTemplateLabelShape shape;
gdouble w, h, r, r1, r2;
glTemplateLabelType *label_type;
shape = GL_TEMPLATE_SHAPE_RECT;
g_warning ("Unknown label style in template");
}
- g_free (style);
+ xmlFree (style);
switch (shape) {
xml191_parse_markup (xmlNodePtr markup_node,
glTemplateLabelType *label_type)
{
- gchar *type;
+ xmlChar *type;
gdouble size;
gdouble x1, y1, x2, y2;
xmlNodePtr 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) {
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");
}
GObject *object;
gdouble x, y;
gdouble w, h;
- gchar *string;
+ xmlChar *string;
GtkJustification just;
gboolean auto_shrink;
gdouble affine[6];
/* 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 */
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;
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);
}
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");
}
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);
xml_parse_pixdata (xmlNodePtr node,
glLabel *label)
{
- gchar *name, *base64;
+ xmlChar *name, *base64;
guchar *stream;
guint stream_length;
gboolean ret;
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);
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;
/* 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);
/* 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 */
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);
}
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")) {