summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-12-19 11:23:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-12-19 11:23:13 (GMT)
commitee66488c3683d1e2b6ac36f523638c42c5649433 (patch)
treea0ea11d5e0652dbe305b67358e441b21fdca104e /generic
parentf64bba0499c121428187fe686da131dca5905e50 (diff)
downloadtcl-ee66488c3683d1e2b6ac36f523638c42c5649433.zip
tcl-ee66488c3683d1e2b6ac36f523638c42c5649433.tar.gz
tcl-ee66488c3683d1e2b6ac36f523638c42c5649433.tar.bz2
Make TclEnsureNamespace() MODULE_SCOPE. Also change some refCount fields from type "int" to "unsigned int" for increased range.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompile.h4
-rw-r--r--generic/tclDisassemble.c4
-rw-r--r--generic/tclInt.h25
-rw-r--r--generic/tclNamesp.c4
-rw-r--r--generic/tclProc.c2
5 files changed, 19 insertions, 20 deletions
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 7f01436..f20ecfd 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -425,11 +425,11 @@ typedef struct ByteCode {
* compiled. If the code is executed if a
* different namespace, it must be
* recompiled. */
- unsigned int nsEpoch; /* Value of nsPtr->resolverEpoch when this
+ unsigned int nsEpoch; /* Value of nsPtr->resolverEpoch when this
* ByteCode was compiled. Used to invalidate
* code when new namespace resolution rules
* are put into effect. */
- int refCount; /* Reference count: set 1 when created plus 1
+ unsigned int refCount; /* Reference count: set 1 when created plus 1
* for each execution of the code currently
* active. This structure can be freed when
* refCount becomes zero. */
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index d61ed42..e07080a 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -254,7 +254,7 @@ DisassembleByteCodeObj(
Tcl_Obj *bufferObj, *fileObj;
TclNewObj(bufferObj);
- if (codePtr->refCount <= 0) {
+ if (!codePtr->refCount) {
return bufferObj; /* Already freed. */
}
@@ -312,7 +312,7 @@ DisassembleByteCodeObj(
int numCompiledLocals = procPtr->numCompiledLocals;
Tcl_AppendPrintfToObj(bufferObj,
- " Proc %p, refCt %d, args %d, compiled locals %d\n",
+ " Proc %p, refCt %u, args %d, compiled locals %d\n",
procPtr, procPtr->refCount, procPtr->numArgs,
numCompiledLocals);
if (numCompiledLocals > 0) {
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 91deb9d..de22924 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -274,7 +274,7 @@ typedef struct Namespace {
* frames for this namespace that are on the
* Tcl call stack. The namespace won't be
* freed until activationCount becomes zero. */
- int refCount; /* Count of references by namespaceName
+ unsigned int refCount; /* Count of references by namespaceName
* objects. The namespace can't be freed until
* refCount becomes zero. */
Tcl_HashTable cmdTable; /* Contains all the commands currently
@@ -299,7 +299,7 @@ typedef struct Namespace {
* registered using "namespace export". */
int maxExportPatterns; /* Mumber of export patterns for which space
* is currently allocated. */
- unsigned int cmdRefEpoch; /* Incremented if a newly added command
+ unsigned int cmdRefEpoch; /* Incremented if a newly added command
* shadows a command for which this namespace
* has already cached a Command* pointer; this
* causes all its cached Command* pointers to
@@ -545,7 +545,7 @@ typedef struct CommandTrace {
struct CommandTrace *nextPtr;
/* Next in list of traces associated with a
* particular command. */
- int refCount; /* Used to ensure this structure is not
+ unsigned int refCount; /* Used to ensure this structure is not
* deleted too early. Keeps track of how many
* pieces of code have a pointer to this
* structure. */
@@ -618,7 +618,7 @@ typedef struct Var {
typedef struct VarInHash {
Var var;
- int refCount; /* Counts number of active uses of this
+ unsigned int refCount; /* Counts number of active uses of this
* variable: 1 for the entry in the hash
* table, 1 for each additional variable whose
* linkPtr points here, 1 for each nested
@@ -950,7 +950,7 @@ typedef struct CompiledLocal {
typedef struct Proc {
struct Interp *iPtr; /* Interpreter for which this command is
* defined. */
- int refCount; /* Reference count: 1 if still present in
+ unsigned int refCount; /* Reference count: 1 if still present in
* command table plus 1 for each call to the
* procedure that is currently active. This
* structure can be freed when refCount
@@ -1067,7 +1067,7 @@ typedef struct AssocData {
*/
typedef struct LocalCache {
- int refCount;
+ unsigned int refCount;
int numVars;
Tcl_Obj *varName0;
} LocalCache;
@@ -1229,7 +1229,7 @@ typedef struct CmdFrame {
typedef struct CFWord {
CmdFrame *framePtr; /* CmdFrame to access. */
int word; /* Index of the word in the command. */
- int refCount; /* Number of times the word is on the
+ unsigned int refCount; /* Number of times the word is on the
* stack. */
} CFWord;
@@ -1634,12 +1634,12 @@ typedef struct Command {
* recreated). */
Namespace *nsPtr; /* Points to the namespace containing this
* command. */
- unsigned int refCount; /* 1 if in command hashtable plus 1 for each
+ unsigned int refCount; /* 1 if in command hashtable plus 1 for each
* reference from a CmdName Tcl object
* representing a command's name in a ByteCode
* instruction sequence. This structure can be
* freed when refCount becomes zero. */
- unsigned int cmdEpoch; /* Incremented to invalidate any references
+ unsigned int cmdEpoch; /* Incremented to invalidate any references
* that point to this command when it is
* renamed, deleted, hidden, or exposed. */
CompileProc *compileProc; /* Procedure called to compile command. NULL
@@ -2384,7 +2384,7 @@ typedef enum TclEolTranslation {
*/
typedef struct List {
- int refCount;
+ unsigned int refCount;
int maxElemCount; /* Total number of element array slots. */
int elemCount; /* Current number of list elements. */
int canonicalFlag; /* Set if the string representation was
@@ -2640,7 +2640,7 @@ typedef void (TclInitProcessGlobalValueProc)(char **valuePtr, unsigned int *leng
typedef struct ProcessGlobalValue {
unsigned int epoch; /* Epoch counter to detect changes in the
* master value. */
- unsigned int numBytes; /* Length of the master string. */
+ unsigned int numBytes; /* Length of the master string. */
char *value; /* The master string value. */
Tcl_Encoding encoding; /* system encoding when master string was
* initialized. */
@@ -2960,8 +2960,7 @@ MODULE_SCOPE char * TclDStringAppendDString(Tcl_DString *dsPtr,
MODULE_SCOPE Tcl_Obj * TclDStringToObj(Tcl_DString *dsPtr);
MODULE_SCOPE Tcl_Obj *const * TclFetchEnsembleRoot(Tcl_Interp *interp,
Tcl_Obj *const *objv, int objc, int *objcPtr);
-Tcl_Namespace * TclEnsureNamespace(
- Tcl_Interp *interp,
+MODULE_SCOPE Tcl_Namespace * TclEnsureNamespace(Tcl_Interp *interp,
Tcl_Namespace *namespacePtr);
MODULE_SCOPE void TclFinalizeAllocSubsystem(void);
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index d212de1..269d06b 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -402,7 +402,7 @@ Tcl_PopCallFrame(
}
if (framePtr->numCompiledLocals > 0) {
TclDeleteCompiledLocalVars(iPtr, framePtr);
- if (--framePtr->localCachePtr->refCount == 0) {
+ if (framePtr->localCachePtr->refCount-- <= 1) {
TclFreeLocalCache(interp, framePtr->localCachePtr);
}
framePtr->localCachePtr = NULL;
@@ -1052,7 +1052,7 @@ Tcl_DeleteNamespace(
* Otherwise, mark it as "dead" so that it can't be used.
*/
- if (nsPtr->refCount == 0) {
+ if (!nsPtr->refCount) {
NamespaceFree(nsPtr);
} else {
nsPtr->flags |= NS_DEAD;
diff --git a/generic/tclProc.c b/generic/tclProc.c
index b89357c..70dc4dc 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -2380,7 +2380,7 @@ FreeLambdaInternalRep(
Proc *procPtr = objPtr->internalRep.twoPtrValue.ptr1;
Tcl_Obj *nsObjPtr = objPtr->internalRep.twoPtrValue.ptr2;
- if (procPtr->refCount-- == 1) {
+ if (procPtr->refCount-- <= 1) {
TclProcCleanupProc(procPtr);
}
TclDecrRefCount(nsObjPtr);