summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclLoad.c25
-rw-r--r--generic/tclStringObj.c6
-rw-r--r--generic/tclStringRep.h6
3 files changed, 26 insertions, 11 deletions
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index 7ea1ebd..ee1862d 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -544,7 +544,7 @@ Tcl_LoadObjCmd(
*
* Tcl_UnloadObjCmd --
*
- * This function is invoked to process the "unload" Tcl command. See the
+ * Implements the the "unload" Tcl command. See the
* user documentation for details on what it does.
*
* Results:
@@ -764,6 +764,23 @@ Tcl_UnloadObjCmd(
return code;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * UnloadLibrary --
+ *
+ * Unloads a library from an interpreter, and also from the process if it
+ * is unloadable, i.e. if it provides an "unload" function.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * See description.
+ *
+ *----------------------------------------------------------------------
+ */
static int
UnloadLibrary(
Tcl_Interp *interp,
@@ -884,11 +901,9 @@ UnloadLibrary(
}
/*
- * The unload function executed fine. Examine the reference count to see
- * if we unload the DLL.
+ * The unload function was called succesfully.
*/
-
Tcl_MutexLock(&libraryMutex);
if (Tcl_IsSafe(target)) {
libraryPtr->safeInterpRefCount--;
@@ -917,7 +932,7 @@ UnloadLibrary(
code = TCL_OK;
if (libraryPtr->safeInterpRefCount <= 0 && libraryPtr->interpRefCount <= 0
- && !keepLibrary) {
+ && (unloadProc != NULL) && !keepLibrary) {
/*
* Unload the shared library from the application memory...
*/
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 2b11877..d43c507 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -145,14 +145,14 @@ typedef struct {
} UniCharString;
#define UNICHAR_STRING_MAXCHARS \
- (int)(((size_t)UINT_MAX - 1 - offsetof(UniCharString, unicode))/sizeof(Tcl_UniChar))
+ (int)(((size_t)UINT_MAX - offsetof(UniCharString, unicode))/sizeof(Tcl_UniChar) - 1)
#define UNICHAR_STRING_SIZE(numChars) \
- (offsetof(UniCharString, unicode) + (((numChars) + 1U) * sizeof(Tcl_UniChar)))
+ (offsetof(UniCharString, unicode) + sizeof(Tcl_UniChar) + ((numChars) * sizeof(Tcl_UniChar)))
#define uniCharStringCheckLimits(numChars) \
do { \
if ((numChars) < 0 || (numChars) > UNICHAR_STRING_MAXCHARS) { \
Tcl_Panic("max length for a Tcl unicode value (%d chars) exceeded", \
- (int)UNICHAR_STRING_MAXCHARS); \
+ UNICHAR_STRING_MAXCHARS); \
} \
} while (0)
#define uniCharStringAttemptAlloc(numChars) \
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index cac4d0b..faa2c2c 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -60,14 +60,14 @@ typedef struct {
} String;
#define STRING_MAXCHARS \
- (int)(((size_t)UINT_MAX - 1 - offsetof(String, unicode))/sizeof(unsigned short))
+ (int)(((size_t)UINT_MAX - offsetof(String, unicode))/sizeof(unsigned short) - 1)
#define STRING_SIZE(numChars) \
- (offsetof(String, unicode) + (((numChars) + 1U) * sizeof(unsigned short)))
+ (offsetof(String, unicode) + sizeof(unsigned short) + ((numChars) * sizeof(unsigned short)))
#define stringCheckLimits(numChars) \
do { \
if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \
Tcl_Panic("max length for a Tcl unicode value (%d chars) exceeded", \
- (int)STRING_MAXCHARS); \
+ STRING_MAXCHARS); \
} \
} while (0)
#define stringAttemptAlloc(numChars) \