summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-08-03 21:46:50 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-08-03 21:46:50 (GMT)
commit477d1446c742c0dc8d659fe7cfed43c49faf83d6 (patch)
treefde92dba2d84d0509666cbf08d25f8ed6c4dfd26
parent78fb095839d48186857702fa71c1d2a9a2491091 (diff)
downloadtcl-477d1446c742c0dc8d659fe7cfed43c49faf83d6.zip
tcl-477d1446c742c0dc8d659fe7cfed43c49faf83d6.tar.gz
tcl-477d1446c742c0dc8d659fe7cfed43c49faf83d6.tar.bz2
Plug leak and clarify code
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclNamesp.c19
2 files changed, 12 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 134fcbe..b169536 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
* generic/tclNamesp.c (MakeCachedEnsembleCommand): Initialize the
epoch field cached in the subcommand. [Bug 989298]
+ (NsEnsembleImplementationCmd): Plug a leak (thanks to Miguel Sofer
+ for spotting it with valgrind) and reduce the number of goto
+ labels to make the code clearer.
2004-08-02 Don Porter <dgp@users.sourceforge.net>
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index e2e2d3f..e38f2da 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -21,7 +21,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclNamesp.c,v 1.43 2004/08/03 20:31:52 dkf Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.44 2004/08/03 21:46:55 dkf Exp $
*/
#include "tclInt.h"
@@ -4813,7 +4813,8 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
if (ensembleCmd->nsPtr == ensemblePtr->nsPtr &&
ensembleCmd->epoch == ensemblePtr->epoch) {
prefixObj = ensembleCmd->realPrefixObj;
- goto runSubcommand;
+ Tcl_IncrRefCount(prefixObj);
+ goto runResultingSubcommand;
}
}
}
@@ -4900,7 +4901,6 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
MakeCachedEnsembleCommand(objv[1], ensemblePtr, fullName, prefixObj);
}
- runSubcommand:
/*
* Do the real work of execution of the subcommand by building an
* array of objects (note that this is potentially not the same
@@ -4923,7 +4923,7 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
ckfree((char *)tempObjv);
return result;
- unknownOrAmbiguousSubcommand:
+ unknownOrAmbiguousSubcommand:
/*
* Have not been able to match the subcommand asked for with a
* real subcommand that we export. See whether a handler has been
@@ -4979,14 +4979,10 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
if (Tcl_ListObjLength(interp, prefixObj, &prefixObjc) != TCL_OK) {
Tcl_DecrRefCount(prefixObj);
Tcl_AddErrorInfo(interp,
- "\n while parsing result of ensemble unknown subcommand handler");
+ "\n while parsing result of ensemble unknown subcommand handler");
return TCL_ERROR;
}
if (prefixObjc > 0) {
- /*
- * Not 'runSubcommand' because we want to get the
- * object refcounting right.
- */
goto runResultingSubcommand;
}
@@ -4994,6 +4990,7 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
* Namespace alive & empty result => reparse.
*/
+ Tcl_DecrRefCount(prefixObj);
goto restartEnsembleParse;
}
if (!Tcl_InterpDeleted(interp)) {
@@ -5019,7 +5016,7 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
}
}
Tcl_AddErrorInfo(interp,
- "\n result of ensemble unknown subcommand handler: ");
+ "\n result of ensemble unknown subcommand handler: ");
Tcl_AddErrorInfo(interp, TclGetString(unknownCmd));
} else {
Tcl_AddErrorInfo(interp,
@@ -5030,12 +5027,14 @@ NsEnsembleImplementationCmd(clientData, interp, objc, objv)
Tcl_Release(ensemblePtr);
return TCL_ERROR;
}
+
/*
* Cannot determine what subcommand to hand off to, so generate a
* (standard) failure message. Note the one odd case compared
* with standard ensemble-like command, which is where a namespace
* has no exported commands at all...
*/
+
Tcl_ResetResult(interp);
if (ensemblePtr->subcommandTable.numEntries == 0) {
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),