]> gitweb.michael.orlitzky.com - libsvgtiny.git/commitdiff
src/svgtiny.c: eliminate pointless NULL check
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 15 Nov 2023 16:55:18 +0000 (11:55 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 20 Nov 2023 16:42:58 +0000 (11:42 -0500)
We initialize the entire struct to zero a few lines earlier.

src/svgtiny.c

index f6319305c3d2f1c76504766879b9ef55a9e219ea..a77e3b46d9f7c0ca382190075f6971af475c4da9 100644 (file)
@@ -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)                                    \