From 9d74009dd53f0d4cbb1101c9cffe0fda7f983bf2 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 15 Nov 2023 11:55:18 -0500 Subject: [PATCH] src/svgtiny.c: eliminate pointless NULL check We initialize the entire struct to zero a few lines earlier. --- src/svgtiny.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/svgtiny.c b/src/svgtiny.c index f631930..a77e3b4 100644 --- a/src/svgtiny.c +++ b/src/svgtiny.c @@ -697,22 +697,21 @@ svgtiny_code svgtiny_parse(struct svgtiny_diagram *diagram, lwc_string_unref(svg_name_lwc); dom_string_unref(svg_name); - /* get graphic dimensions */ + /* initialize the state struct with zeros */ memset(&state, 0, sizeof(state)); + + /* get graphic dimensions */ state.diagram = diagram; state.document = document; state.viewport_width = viewport_width; state.viewport_height = viewport_height; - /* Initialize CSS context */ - if (state.select_ctx == NULL) { - css_code = css_select_ctx_create(&state.select_ctx); - if (css_code != CSS_OK) { - dom_node_unref(svg); - dom_node_unref(document); - return svgtiny_LIBCSS_ERROR; - } + css_code = css_select_ctx_create(&state.select_ctx); + if (css_code != CSS_OK) { + dom_node_unref(svg); + dom_node_unref(document); + return svgtiny_LIBCSS_ERROR; } #define SVGTINY_STRING_ACTION2(s,n) \ -- 2.43.2