X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsvgtiny.c;h=137f2b065d9afed42440342a3c24d781e8bcf112;hb=461d400085eba848898d74c92a820b5e3e1d6c49;hp=18884a11f45012ab3ca2940971b2da829d736691;hpb=9275ab30890fe7def93dcfe913c9209d32c2d00e;p=libsvgtiny.git diff --git a/src/svgtiny.c b/src/svgtiny.c index 18884a1..137f2b0 100644 --- a/src/svgtiny.c +++ b/src/svgtiny.c @@ -205,10 +205,18 @@ svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram, dom_node_unref(document); cleanup: + if (state.gradient_x1 != NULL) + dom_string_unref(state.gradient_x1); + if (state.gradient_x2 != NULL) + dom_string_unref(state.gradient_x2); + if (state.gradient_y1 != NULL) + dom_string_unref(state.gradient_y1); + if (state.gradient_y2 != NULL) + dom_string_unref(state.gradient_y2); #define SVGTINY_STRING_ACTION2(s,n) \ if (state.interned_##s != NULL) \ dom_string_unref(state.interned_##s); -//#include "svgtiny_strings.h" +#include "svgtiny_strings.h" #undef SVGTINY_STRING_ACTION2 return code; } @@ -238,7 +246,7 @@ svgtiny_code svgtiny_parse_svg(dom_element *svg, if (view_box) { char *s = strndup(dom_string_data(view_box), - dom_string_length(view_box)); + dom_string_byte_length(view_box)); float min_x, min_y, vwidth, vheight; if (sscanf(s, "%f,%f,%f,%f", &min_x, &min_y, &vwidth, &vheight) == 4 || @@ -255,7 +263,7 @@ svgtiny_code svgtiny_parse_svg(dom_element *svg, svgtiny_parse_transform_attributes(svg, &state); - exc = dom_node_get_first_child(svg, &child); + exc = dom_node_get_first_child(svg, (dom_node **) (void *) &child); if (exc != DOM_NO_ERR) { return svgtiny_LIBDOM_ERROR; } @@ -315,7 +323,8 @@ svgtiny_code svgtiny_parse_svg(dom_element *svg, dom_node_unref(child); return code; } - exc = dom_node_get_next_sibling(child, &next); + exc = dom_node_get_next_sibling(child, + (dom_node **) (void *) &next); dom_node_unref(child); if (exc != DOM_NO_ERR) { return svgtiny_LIBDOM_ERROR; @@ -364,7 +373,7 @@ svgtiny_code svgtiny_parse_path(dom_element *path, } s = path_d = strndup(dom_string_data(path_d_str), - dom_string_length(path_d_str)); + dom_string_byte_length(path_d_str)); dom_string_unref(path_d_str); if (s == NULL) { return svgtiny_OUT_OF_MEMORY; @@ -895,7 +904,7 @@ svgtiny_code svgtiny_parse_poly(dom_element *poly, } s = points = strndup(dom_string_data(points_str), - dom_string_length(points_str)); + dom_string_byte_length(points_str)); dom_string_unref(points_str); /* read points attribute */ if (s == NULL) @@ -1000,7 +1009,7 @@ svgtiny_code svgtiny_parse_text(dom_element *text, return svgtiny_LIBDOM_ERROR; } shape->text = strndup(dom_string_data(content), - dom_string_length(content)); + dom_string_byte_length(content)); dom_string_unref(content); shape->text_x = px; shape->text_y = py; @@ -1108,7 +1117,7 @@ static float _svgtiny_parse_length(const char *s, int viewport_size, float svgtiny_parse_length(dom_string *s, int viewport_size, const struct svgtiny_parse_state state) { - char *ss = strndup(dom_string_data(s), dom_string_length(s)); + char *ss = strndup(dom_string_data(s), dom_string_byte_length(s)); float ret = _svgtiny_parse_length(ss, viewport_size, state); free(ss); return ret; @@ -1146,7 +1155,7 @@ void svgtiny_parse_paint_attributes(const dom_element *node, exc = dom_element_get_attribute(node, state->interned_style, &attr); if (exc == DOM_NO_ERR && attr != NULL) { char *style = strndup(dom_string_data(attr), - dom_string_length(attr)); + dom_string_byte_length(attr)); const char *s; char *value; if ((s = strstr(style, "fill:"))) { @@ -1246,7 +1255,7 @@ static void _svgtiny_parse_color(const char *s, svgtiny_colour *c, void svgtiny_parse_color(dom_string *s, svgtiny_colour *c, struct svgtiny_parse_state *state) { - char *ss = strndup(dom_string_data(s), dom_string_length(s)); + char *ss = strndup(dom_string_data(s), dom_string_byte_length(s)); _svgtiny_parse_color(ss, c, state); free(ss); } @@ -1298,7 +1307,7 @@ void svgtiny_parse_transform_attributes(dom_element *node, &attr); if (exc == DOM_NO_ERR && attr != NULL) { transform = strndup(dom_string_data(attr), - dom_string_length(attr)); + dom_string_byte_length(attr)); svgtiny_parse_transform(transform, &state->ctm.a, &state->ctm.b, &state->ctm.c, &state->ctm.d, &state->ctm.e, &state->ctm.f);