diff options
Diffstat (limited to 'web/web_svg.c')
-rw-r--r-- | web/web_svg.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/web/web_svg.c b/web/web_svg.c index 485583d..8714e69 100644 --- a/web/web_svg.c +++ b/web/web_svg.c @@ -188,27 +188,24 @@ static void draw_board() static void create_board() { + char buf[512]; + struct dom_elem *e = svg_elem_init("svg", 2); dom_elem_add_attr(e, "id", "dartboard"); - char *viewbox; - asprintf(&viewbox, "0 0 %f %f", DIAMETER, DIAMETER); - dom_elem_add_attr(e, "viewBox", viewbox); - free(viewbox); + sprintf(buf, "0 0 %f %f", DIAMETER, DIAMETER); + dom_elem_add_attr(e, "viewBox", buf); dom_append_elemv("#dartboard-container", 1, &e); struct dom_elem **elemv = malloc(2 * sizeof(*elemv)); int elemc = 0; - char *transform; - asprintf(&transform, "translate(%f %f) scale(1 -1)", - DIAMETER/2, DIAMETER/2); + sprintf(buf, "translate(%f %f) scale(1 -1)", DIAMETER/2, DIAMETER/2); for (int i = 0; i < 2; ++i) { struct dom_elem *e = svg_elem_init("g", 2); dom_elem_add_attr(e, "class", i ? "overlay" : "base"); - dom_elem_add_attr(e, "transform", transform); + dom_elem_add_attr(e, "transform", buf); elemv[elemc++] = e; } - free(transform); dom_append_elemv("#dartboard", elemc, elemv); |