summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-28 12:24:17 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-28 12:24:17 (GMT)
commita7e88b5393d87cb3ccadc57eb8d5c00b02c939f6 (patch)
treeb36424e6d7a9e7c0bd5730a3fcff9975ef6836fb
parentd4140ec31b18515b482006a2d9cac7e2d281f8db (diff)
parent5cb710df9af162eecdda7380baae24d5afd8fa3d (diff)
downloadtcl-a7e88b5393d87cb3ccadc57eb8d5c00b02c939f6.zip
tcl-a7e88b5393d87cb3ccadc57eb8d5c00b02c939f6.tar.gz
tcl-a7e88b5393d87cb3ccadc57eb8d5c00b02c939f6.tar.bz2
Merge 8.7. Register "string" objType when TCL_UTF_MAX=3 (fixes regression in previous commit)
-rw-r--r--generic/tclCkalloc.c34
-rw-r--r--generic/tclIO.c4
-rw-r--r--generic/tclLink.c12
-rw-r--r--generic/tclObj.c2
4 files changed, 26 insertions, 26 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index d0fa300..fbf7b81 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -36,7 +36,7 @@
typedef struct MemTag {
size_t refCount; /* Number of mem_headers referencing this
* tag. */
- char string[1]; /* Actual size of string will be as large as
+ char string[TCLFLEXARRAY]; /* Actual size of string will be as large as
* needed for actual tag. This must be the
* last field in the structure. */
} MemTag;
@@ -65,7 +65,7 @@ struct mem_header {
/* Aligns body on 8-byte boundary, plus
* provides at least 8 additional guard bytes
* to detect underruns. */
- char body[1]; /* First byte of client's space. Actual size
+ char body[TCLFLEXARRAY]; /* First byte of client's space. Actual size
* of this field will be larger than one. */
};
@@ -93,8 +93,8 @@ static unsigned int total_mallocs = 0;
static unsigned int total_frees = 0;
static size_t current_bytes_malloced = 0;
static size_t maximum_bytes_malloced = 0;
-static unsigned int current_malloc_packets = 0;
-static unsigned int maximum_malloc_packets = 0;
+static size_t current_malloc_packets = 0;
+static size_t maximum_malloc_packets = 0;
static unsigned int break_on_malloc = 0;
static unsigned int trace_on_at_malloc = 0;
static int alloc_tracing = FALSE;
@@ -188,9 +188,9 @@ TclDumpMemoryInfo(
sprintf(buf,
"total mallocs %10u\n"
"total frees %10u\n"
- "current packets allocated %10u\n"
+ "current packets allocated %10" TCL_Z_MODIFIER "u\n"
"current bytes allocated %10" TCL_Z_MODIFIER "u\n"
- "maximum packets allocated %10u\n"
+ "maximum packets allocated %10" TCL_Z_MODIFIER "u\n"
"maximum bytes allocated %10" TCL_Z_MODIFIER "u\n",
total_mallocs,
total_frees,
@@ -252,7 +252,7 @@ ValidateMemory(
}
}
if (guard_failed) {
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
fprintf(stderr, "low guard failed at %p, %s %d\n",
memHeaderP->body, file, line);
fflush(stderr); /* In case name pointer is bad. */
@@ -274,7 +274,7 @@ ValidateMemory(
}
if (guard_failed) {
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
fprintf(stderr, "high guard failed at %p, %s %d\n",
memHeaderP->body, file, line);
fflush(stderr); /* In case name pointer is bad. */
@@ -406,13 +406,13 @@ Tcl_DbCkalloc(
}
/* Don't let size argument to TclpAlloc overflow */
- if (size <= UINT_MAX - HIGH_GUARD_SIZE -sizeof(struct mem_header)) {
+ if (size <= UINT_MAX - offsetof(struct mem_header, body) - 1U - HIGH_GUARD_SIZE) {
result = (struct mem_header *) TclpAlloc(size +
- sizeof(struct mem_header) + HIGH_GUARD_SIZE);
+ offsetof(struct mem_header, body) + 1U + HIGH_GUARD_SIZE);
}
if (result == NULL) {
fflush(stdout);
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
Tcl_Panic("unable to alloc %u bytes, %s line %d", size, file, line);
}
@@ -424,7 +424,7 @@ Tcl_DbCkalloc(
if (init_malloced_bodies) {
memset(result, GUARD_VALUE,
- size + sizeof(struct mem_header) + HIGH_GUARD_SIZE);
+ offsetof(struct mem_header, body) + 1U + HIGH_GUARD_SIZE + size);
} else {
memset(result->low_guard, GUARD_VALUE, LOW_GUARD_SIZE);
memset(result->body + size, GUARD_VALUE, HIGH_GUARD_SIZE);
@@ -496,13 +496,13 @@ Tcl_AttemptDbCkalloc(
}
/* Don't let size argument to TclpAlloc overflow */
- if (size <= UINT_MAX - HIGH_GUARD_SIZE - sizeof(struct mem_header)) {
+ if (size <= UINT_MAX - offsetof(struct mem_header, body) - 1U - HIGH_GUARD_SIZE) {
result = (struct mem_header *) TclpAlloc(size +
- sizeof(struct mem_header) + HIGH_GUARD_SIZE);
+ offsetof(struct mem_header, body) + 1U + HIGH_GUARD_SIZE);
}
if (result == NULL) {
fflush(stdout);
- TclDumpMemoryInfo((ClientData) stderr, 0);
+ TclDumpMemoryInfo(stderr, 0);
return NULL;
}
@@ -513,7 +513,7 @@ Tcl_AttemptDbCkalloc(
*/
if (init_malloced_bodies) {
memset(result, GUARD_VALUE,
- size + sizeof(struct mem_header) + HIGH_GUARD_SIZE);
+ offsetof(struct mem_header, body) + 1U + HIGH_GUARD_SIZE + size);
} else {
memset(result->low_guard, GUARD_VALUE, LOW_GUARD_SIZE);
memset(result->body + size, GUARD_VALUE, HIGH_GUARD_SIZE);
@@ -857,7 +857,7 @@ MemoryCmd(
}
if (strcmp(TclGetString(objv[1]),"info") == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "%-25s %10u\n%-25s %10u\n%-25s %10u\n%-25s %10" TCL_Z_MODIFIER"u\n%-25s %10u\n%-25s %10" TCL_Z_MODIFIER "u\n",
+ "%-25s %10u\n%-25s %10u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n%-25s %10" TCL_Z_MODIFIER "u\n",
"total mallocs", total_mallocs, "total frees", total_frees,
"current packets allocated", current_malloc_packets,
"current bytes allocated", current_bytes_malloced,
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 59aa50f..af14071 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -103,7 +103,7 @@ typedef struct CopyState {
Tcl_Interp *interp; /* Interp that started the copy. */
Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */
int bufSize; /* Size of appended buffer. */
- char buffer[1]; /* Copy buffer, this must be the last
+ char buffer[TCLFLEXARRAY]; /* Copy buffer, this must be the last
* field. */
} CopyState;
@@ -9246,7 +9246,7 @@ TclCopyChannel(
* completed.
*/
- csPtr = (CopyState *)ckalloc(sizeof(CopyState) + !moveBytes * inStatePtr->bufSize);
+ csPtr = (CopyState *)ckalloc(offsetof(CopyState, buffer) + 1U + !moveBytes * inStatePtr->bufSize);
csPtr->bufSize = !moveBytes * inStatePtr->bufSize;
csPtr->readPtr = inPtr;
csPtr->writePtr = outPtr;
diff --git a/generic/tclLink.c b/generic/tclLink.c
index 39f5345..ee77654 100644
--- a/generic/tclLink.c
+++ b/generic/tclLink.c
@@ -1071,7 +1071,7 @@ LinkTraceProc(
if (linkPtr->flags & LINK_ALLOC_LAST) {
for (i=0; i < objc; i++) {
if (GetInt(objv[i], &valueInt)
- || !InRange(0, valueInt, UCHAR_MAX)) {
+ || !InRange(0, valueInt, (int)UCHAR_MAX)) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
return (char *)
@@ -1081,7 +1081,7 @@ LinkTraceProc(
}
} else {
if (GetInt(valueObj, &valueInt)
- || !InRange(0, valueInt, UCHAR_MAX)) {
+ || !InRange(0, valueInt, (int)UCHAR_MAX)) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned char value";
@@ -1117,7 +1117,7 @@ LinkTraceProc(
if (linkPtr->flags & LINK_ALLOC_LAST) {
for (i=0; i < objc; i++) {
if (GetInt(objv[i], &valueInt)
- || !InRange(0, valueInt, USHRT_MAX)) {
+ || !InRange(0, valueInt, (int)USHRT_MAX)) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
return (char *)
@@ -1127,7 +1127,7 @@ LinkTraceProc(
}
} else {
if (GetInt(valueObj, &valueInt)
- || !InRange(0, valueInt, USHRT_MAX)) {
+ || !InRange(0, valueInt, (int)USHRT_MAX)) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned short value";
@@ -1141,7 +1141,7 @@ LinkTraceProc(
if (linkPtr->flags & LINK_ALLOC_LAST) {
for (i=0; i < objc; i++) {
if (GetWide(objv[i], &valueWide)
- || !InRange(0, valueWide, UINT_MAX)) {
+ || !InRange(0, valueWide, (Tcl_WideInt)UINT_MAX)) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
return (char *)
@@ -1151,7 +1151,7 @@ LinkTraceProc(
}
} else {
if (GetWide(valueObj, &valueWide)
- || !InRange(0, valueWide, UINT_MAX)) {
+ || !InRange(0, valueWide, (Tcl_WideInt)UINT_MAX)) {
Tcl_ObjSetVar2(interp, linkPtr->varName, NULL,
ObjValue(linkPtr), TCL_GLOBAL_ONLY);
return (char *) "variable must have unsigned int value";
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 7596880..15fe98f 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -387,7 +387,7 @@ TclInitObjSubsystem(void)
Tcl_RegisterObjType(&tclByteArrayType);
Tcl_RegisterObjType(&tclDoubleType);
-#if (TCL_UTF_MAX) > 3 && !defined(TCL_NO_DEPRECATED)
+#if (TCL_UTF_MAX < 4) || !defined(TCL_NO_DEPRECATED)
Tcl_RegisterObjType(&tclStringType);
#endif
Tcl_RegisterObjType(&tclListType);