summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-24 20:10:25 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-01-24 20:10:25 (GMT)
commitf786cb097f2b4dedaf17c38b8246e76df1a73ce5 (patch)
tree44800cd8681e698777665467b8e06d5b2432d9df /generic/tclIO.c
parent5a02d5db9cec007d16a60b24bd8cd0b1912d123f (diff)
downloadtcl-f786cb097f2b4dedaf17c38b8246e76df1a73ce5.zip
tcl-f786cb097f2b4dedaf17c38b8246e76df1a73ce5.tar.gz
tcl-f786cb097f2b4dedaf17c38b8246e76df1a73ce5.tar.bz2
Another round of int -> size_t modifications, so strings > 2Gb are handled correctly on 64-bit platforms.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 4a32216..ca4f461 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -673,7 +673,7 @@ TclFinalizeIOSubsystem(void)
statePtr->refCount--;
}
- if (statePtr->refCount <= 0) {
+ if (statePtr->refCount + 1 <= 1) {
/*
* Close it only if the refcount indicates that the channel is
* not referenced from any interpreter. If it is, that
@@ -1091,7 +1091,7 @@ CheckForStdChannelsBeingClosed(
if (tsdPtr->stdinInitialized == 1
&& tsdPtr->stdinChannel != NULL
&& statePtr == ((Channel *)tsdPtr->stdinChannel)->state) {
- if (statePtr->refCount < 2) {
+ if (statePtr->refCount + 1 < 3) {
statePtr->refCount = 0;
tsdPtr->stdinChannel = NULL;
return;
@@ -1099,7 +1099,7 @@ CheckForStdChannelsBeingClosed(
} else if (tsdPtr->stdoutInitialized == 1
&& tsdPtr->stdoutChannel != NULL
&& statePtr == ((Channel *)tsdPtr->stdoutChannel)->state) {
- if (statePtr->refCount < 2) {
+ if (statePtr->refCount + 1 < 3) {
statePtr->refCount = 0;
tsdPtr->stdoutChannel = NULL;
return;
@@ -1107,7 +1107,7 @@ CheckForStdChannelsBeingClosed(
} else if (tsdPtr->stderrInitialized == 1
&& tsdPtr->stderrChannel != NULL
&& statePtr == ((Channel *)tsdPtr->stderrChannel)->state) {
- if (statePtr->refCount < 2) {
+ if (statePtr->refCount + 1 < 3) {
statePtr->refCount = 0;
tsdPtr->stderrChannel = NULL;
return;
@@ -1269,7 +1269,7 @@ Tcl_UnregisterChannel(
* If the refCount reached zero, close the actual channel.
*/
- if (statePtr->refCount <= 0) {
+ if (statePtr->refCount + 1 <= 1) {
Tcl_Preserve(statePtr);
if (!GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
/*
@@ -2015,7 +2015,7 @@ static void
ChannelFree(
Channel *chanPtr)
{
- if (chanPtr->refCount == 0) {
+ if (!chanPtr->refCount) {
Tcl_Free(chanPtr);
return;
}
@@ -2187,7 +2187,7 @@ Tcl_UnstackChannel(
* necessary.
*/
- if (statePtr->refCount <= 0) {
+ if (statePtr->refCount + 1 <= 1) {
if (Tcl_Close(interp, chan) != TCL_OK) {
/*
* TIP #219, Tcl Channel Reflection API.
@@ -2487,7 +2487,7 @@ static void
PreserveChannelBuffer(
ChannelBuffer *bufPtr)
{
- if (bufPtr->refCount == 0) {
+ if (!bufPtr->refCount) {
Tcl_Panic("Reuse of ChannelBuffer! %p", bufPtr);
}
bufPtr->refCount++;
@@ -2507,7 +2507,7 @@ static int
IsShared(
ChannelBuffer *bufPtr)
{
- return bufPtr->refCount > 1;
+ return bufPtr->refCount + 1 > 2;
}
/*
@@ -2943,7 +2943,7 @@ FlushChannel(
* current output buffer.
*/
- if (GotFlag(statePtr, CHANNEL_CLOSED) && (statePtr->refCount <= 0) &&
+ if (GotFlag(statePtr, CHANNEL_CLOSED) && (statePtr->refCount + 1 <= 1) &&
(statePtr->outQueueHead == NULL) &&
((statePtr->curOutPtr == NULL) ||
IsBufferEmpty(statePtr->curOutPtr))) {
@@ -3410,7 +3410,7 @@ Tcl_Close(
statePtr = chanPtr->state;
chanPtr = statePtr->topChanPtr;
- if (statePtr->refCount > 0) {
+ if (statePtr->refCount + 1 > 1) {
Tcl_Panic("called Tcl_Close on channel with refCount > 0");
}
@@ -6108,7 +6108,7 @@ ReadChars(
(void) TclGetStringFromObj(objPtr, &numBytes);
Tcl_AppendToObj(objPtr, NULL, dstLimit);
if (toRead == srcLen) {
- unsigned int size;
+ size_t size;
dst = TclGetStringStorage(objPtr, &size) + numBytes;
dstLimit = size - numBytes;
@@ -10359,7 +10359,7 @@ Tcl_IsChannelShared(
ChannelState *statePtr = ((Channel *) chan)->state;
/* State of real channel structure. */
- return ((statePtr->refCount > 1) ? 1 : 0);
+ return ((statePtr->refCount + 1 > 2) ? 1 : 0);
}
/*