summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-29 09:39:48 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-03-29 09:39:48 (GMT)
commit9b5304eb3a0e69d76a593c818395cb4025ed8121 (patch)
tree94c096fa319913227c7b9901ed70c98ee1dbcc21 /generic
parentf768cd1df73e1d1801bef8b03e89609d1bb6f885 (diff)
parent34de5875e05c12da0b6164436bdc42c17c307c4e (diff)
downloadtcl-9b5304eb3a0e69d76a593c818395cb4025ed8121.zip
tcl-9b5304eb3a0e69d76a593c818395cb4025ed8121.tar.gz
tcl-9b5304eb3a0e69d76a593c818395cb4025ed8121.tar.bz2
Merge 9.0
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCkalloc.c26
-rw-r--r--generic/tclIO.c4
-rw-r--r--generic/tclLink.c12
3 files changed, 21 insertions, 21 deletions
diff --git a/generic/tclCkalloc.c b/generic/tclCkalloc.c
index af2c21c..6a6ed31 100644
--- a/generic/tclCkalloc.c
+++ b/generic/tclCkalloc.c
@@ -36,7 +36,7 @@
typedef struct {
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,
@@ -406,9 +406,9 @@ 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);
@@ -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,9 +496,9 @@ 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);
@@ -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 55a4792..98675da 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;
@@ -9196,7 +9196,7 @@ TclCopyChannel(
* completed.
*/
- csPtr = (CopyState *)Tcl_Alloc(sizeof(CopyState) + !moveBytes * inStatePtr->bufSize);
+ csPtr = (CopyState *)Tcl_Alloc(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 c345614..62c3370 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";