if (!diagram)
return 0;
- diagram->doc = 0;
- diagram->svg = 0;
diagram->shape = 0;
diagram->shape_count = 0;
XML_PARSE_DTDVALID /* needed for xmlGetID to work */);
if (!document)
return svgtiny_LIBXML_ERROR;
- diagram->doc = document;
/*xmlDebugDumpDocument(stderr, document);*/
return svgtiny_NOT_SVG;
if (strcmp((const char *) svg->name, "svg") != 0)
return svgtiny_NOT_SVG;
- diagram->svg = svg;
/* get graphic dimensions */
float x, y, width, height;
state.diagram = diagram;
- state.document = diagram->doc;
+ state.document = document;
state.viewport_width = viewport_width;
state.viewport_height = viewport_height;
svgtiny_parse_position_attributes(svg, state, &x, &y, &width, &height);
state.stroke = svgtiny_TRANSPARENT;
state.stroke_width = 1;
- return svgtiny_parse_svg(svg, state);
+ svgtiny_parse_svg(svg, state);
+
+ xmlFreeDoc(document);
+
+ return svgtiny_OK;
}
}
}
+
+void svgtiny_free(struct svgtiny_diagram *svg)
+{
+ assert(svg);
+
+ for (unsigned int i = 0; i != svg->shape_count; i++) {
+ free(svg->shape[i].path);
+ free(svg->shape[i].text);
+ }
+
+ free(svg->shape);
+
+ free(svg);
+}
+