From: Matthew Fernandez Date: Thu, 8 Sep 2022 00:27:49 +0000 (-0700) Subject: tclpkg: remove 'Tcl_Alloc' failure handling code X-Git-Tag: 6.0.2~7^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39e923805a639c53ae6795c539db6a787ea8b7ed;p=graphviz tclpkg: remove 'Tcl_Alloc' failure handling code `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 --- diff --git a/tclpkg/gdtclft/gdtclft.c b/tclpkg/gdtclft/gdtclft.c index e06c1f1ce..310756919 100644 --- a/tclpkg/gdtclft/gdtclft.c +++ b/tclpkg/gdtclft/gdtclft.c @@ -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++)