]> granicus.if.org Git - graphviz/commitdiff
tclpkg: remove 'Tcl_Alloc' failure handling code
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Sep 2022 00:27:49 +0000 (17:27 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 10 Oct 2022 14:59:07 +0000 (07:59 -0700)
`Tcl_Alloc` panics the containing TCL interpreter on error.¹ There is no need to
anticipate it returning `NULL`.

¹ https://www.tcl-lang.org/man/tcl/TclLib/Alloc.htm

tclpkg/gdtclft/gdtclft.c

index e06c1f1ce4611341aa2968d488fbd1009b8bc6ad..310756919820b402d80835b91ee21b090f4b6d8b 100644 (file)
@@ -859,11 +859,6 @@ tclGdStyleCmd(Tcl_Interp * interp, int argc, Tcl_Obj * CONST objv[])
            return TCL_ERROR;
 
     colors = (int *) Tcl_Alloc(ncolor * sizeof(int));
-    if (colors == NULL) {
-       Tcl_SetResult(interp, "Memory allocation failed", TCL_STATIC);
-       retval = TCL_ERROR;
-       goto out;
-    }
     /* Get the color values. */
     for (i = 0; i < ncolor; i++)
        if (Tcl_GetIntFromObj(interp, colorObjv[i], &colors[i]) != TCL_OK) {
@@ -875,7 +870,6 @@ tclGdStyleCmd(Tcl_Interp * interp, int argc, Tcl_Obj * CONST objv[])
     if (retval == TCL_OK)
        gdImageSetStyle(im, colors, ncolor);
 
-  out:
     /* Free the colors. */
     if (colors != NULL)
        Tcl_Free((char *) colors);
@@ -1066,11 +1060,6 @@ tclGdPolygonCmd(Tcl_Interp * interp, int argc, Tcl_Obj * CONST objv[])
     }
 
     points = (gdPointPtr) Tcl_Alloc(npoints * sizeof(gdPoint));
-    if (points == NULL) {
-       Tcl_SetResult(interp, "Memory allocation failed", TCL_STATIC);
-       retval = TCL_ERROR;
-       goto out;
-    }
 
     /* Get the point values. */
     for (i = 0; i < npoints; i++)