summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-02-05 19:24:27 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-02-05 19:24:27 (GMT)
commita3dd509ce7199eabd840269dff98a6c2e984c482 (patch)
tree33ac77a5fda1c01bd50093e65d6b2c1735c2dc90
parent08fa42eaa0798c68ec6a365e3f2ab1905e97b287 (diff)
parentdf3478c0c508d7065be2d48ab3b48f405dd80b18 (diff)
downloadtcl-a3dd509ce7199eabd840269dff98a6c2e984c482.zip
tcl-a3dd509ce7199eabd840269dff98a6c2e984c482.tar.gz
tcl-a3dd509ce7199eabd840269dff98a6c2e984c482.tar.bz2
merge 8.5
-rw-r--r--generic/tclIO.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index b3af1f5..5a25243 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -166,6 +166,7 @@ static ChannelBuffer * AllocChannelBuffer(int length);
static void PreserveChannelBuffer(ChannelBuffer *bufPtr);
static void ReleaseChannelBuffer(ChannelBuffer *bufPtr);
static int IsShared(ChannelBuffer *bufPtr);
+static void ChannelFree(Channel *chanPtr);
static void ChannelTimerProc(ClientData clientData);
static int ChanRead(Channel *chanPtr, char *dst, int dstSize);
static int CheckChannelErrors(ChannelState *statePtr,
@@ -1819,6 +1820,16 @@ TclChannelRelease(
}
}
+static void
+ChannelFree(
+ Channel *chanPtr)
+{
+ if (chanPtr->refCount == 0) {
+ ckfree((char *)chanPtr);
+ return;
+ }
+ chanPtr->typePtr = NULL;
+}
/*
*----------------------------------------------------------------------
@@ -1977,7 +1988,7 @@ Tcl_UnstackChannel(
interp, 0);
}
- chanPtr->typePtr = NULL;
+ ChannelFree(chanPtr);
UpdateInterest(statePtr->topChanPtr);
@@ -2916,7 +2927,8 @@ CloseChannel(
statePtr->topChanPtr = downChanPtr;
downChanPtr->upChanPtr = NULL;
- chanPtr->typePtr = NULL;
+
+ ChannelFree(chanPtr);
return Tcl_Close(interp, (Tcl_Channel) downChanPtr);
}
@@ -2927,7 +2939,7 @@ CloseChannel(
* stack, make sure to free the ChannelState structure associated with it.
*/
- chanPtr->typePtr = NULL;
+ ChannelFree(chanPtr);
Tcl_EventuallyFree(statePtr, TCL_DYNAMIC);