diff options
author | sebres <sebres@users.sourceforge.net> | 2017-05-29 19:44:55 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2017-05-29 19:44:55 (GMT) |
commit | dbdad35b2d1d80a8f0c8220d914eda4ac301174f (patch) | |
tree | 05ad1881dfa10438260bbabdc6d2713bc1b5ade8 /generic | |
parent | d97d4ac534c4858f49230be22cdb9cb429b939fa (diff) | |
parent | 3ae95af52ca24414d723b827fc99cc1a2b94f778 (diff) | |
download | tcl-dbdad35b2d1d80a8f0c8220d914eda4ac301174f.zip tcl-dbdad35b2d1d80a8f0c8220d914eda4ac301174f.tar.gz tcl-dbdad35b2d1d80a8f0c8220d914eda4ac301174f.tar.bz2 |
merge core-8-6-branch
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCmdIL.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index e2093bb..4a11c3b 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3682,7 +3682,7 @@ Tcl_LsortObjCmd( int sortMode = SORTMODE_ASCII; int group, groupSize, groupOffset, idx, allocatedIndexVector = 0; Tcl_Obj *resultPtr, *cmdPtr, **listObjPtrs, *listObj, *indexPtr; - SortElement *elementArray, *elementPtr; + SortElement *elementArray = NULL, *elementPtr; SortInfo sortInfo; /* Information about this sort that needs to * be passed to the comparison function. */ # define NUM_LISTS 30 @@ -3728,7 +3728,7 @@ Tcl_LsortObjCmd( if (Tcl_GetIndexFromObj(interp, objv[i], switches, "option", 0, &index) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } switch ((enum Lsort_Switches) index) { case LSORT_ASCII: @@ -3741,7 +3741,7 @@ Tcl_LsortObjCmd( "by comparison command", -1)); Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL); sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } sortInfo.sortMode = SORTMODE_COMMAND; cmdPtr = objv[i+1]; @@ -3766,12 +3766,12 @@ Tcl_LsortObjCmd( -1)); Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL); sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } if (TclListObjGetElements(interp, objv[i+1], &indexc, &indexv) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } /* @@ -3788,7 +3788,7 @@ Tcl_LsortObjCmd( Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (-index option item number %d)", j)); sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } } indexPtr = objv[i+1]; @@ -3817,11 +3817,11 @@ Tcl_LsortObjCmd( "followed by stride length", -1)); Tcl_SetErrorCode(interp, "TCL", "ARGUMENT", "MISSING", NULL); sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } if (Tcl_GetIntFromObj(interp, objv[i+1], &groupSize) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } if (groupSize < 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -3829,7 +3829,7 @@ Tcl_LsortObjCmd( Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LSORT", "BADSTRIDE", NULL); sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } group = 1; i++; @@ -3884,7 +3884,7 @@ Tcl_LsortObjCmd( listObj = TclListObjCopy(interp, listObj); if (listObj == NULL) { sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } /* @@ -3902,7 +3902,7 @@ Tcl_LsortObjCmd( Tcl_IncrRefCount(newObjPtr); TclDecrRefCount(newObjPtr); sortInfo.resultCode = TCL_ERROR; - goto done2; + goto done; } Tcl_ListObjAppendElement(interp, newCommandPtr, Tcl_NewObj()); sortInfo.compareCmdPtr = newCommandPtr; @@ -3995,7 +3995,7 @@ Tcl_LsortObjCmd( * begins sorting it into the sublists as it appears. */ - elementArray = TclStackAlloc(interp, length * sizeof(SortElement)); + elementArray = ckalloc(length * sizeof(SortElement)); for (i=0; i < length; i++){ idx = groupSize * i + groupOffset; @@ -4005,7 +4005,7 @@ Tcl_LsortObjCmd( */ indexPtr = SelectObjFromSublist(listObjPtrs[idx], &sortInfo); if (sortInfo.resultCode != TCL_OK) { - goto done1; + goto done; } } else { indexPtr = listObjPtrs[idx]; @@ -4022,7 +4022,7 @@ Tcl_LsortObjCmd( if (TclGetWideIntFromObj(sortInfo.interp, indexPtr, &a) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; - goto done1; + goto done; } elementArray[i].collationKey.wideValue = a; } else if (sortMode == SORTMODE_REAL) { @@ -4031,7 +4031,7 @@ Tcl_LsortObjCmd( if (Tcl_GetDoubleFromObj(sortInfo.interp, indexPtr, &a) != TCL_OK) { sortInfo.resultCode = TCL_ERROR; - goto done1; + goto done; } elementArray[i].collationKey.doubleValue = a; } else { @@ -4118,19 +4118,18 @@ Tcl_LsortObjCmd( Tcl_SetObjResult(interp, resultPtr); } - done1: - TclStackFree(interp, elementArray); - done: if (sortMode == SORTMODE_COMMAND) { TclDecrRefCount(sortInfo.compareCmdPtr); TclDecrRefCount(listObj); sortInfo.compareCmdPtr = NULL; } - done2: if (allocatedIndexVector) { TclStackFree(interp, sortInfo.indexv); } + if (elementArray) { + ckfree(elementArray); + } return sortInfo.resultCode; } |