From 39e923805a639c53ae6795c539db6a787ea8b7ed Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 7 Sep 2022 17:27:49 -0700 Subject: [PATCH] tclpkg: remove 'Tcl_Alloc' failure handling code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit `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 | 11 ----------- 1 file changed, 11 deletions(-) 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++) -- 2.40.0