diff options
author | andreas_kupries <akupries@shaw.ca> | 2001-07-18 17:17:19 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2001-07-18 17:17:19 (GMT) |
commit | d31b1fb794a7d6495a9f02424a6bd82cd8f97d70 (patch) | |
tree | f339c338faebb4910188564c016a8f7d59f7e099 | |
parent | 245af7255bba95cf98f5fdc149a9fdc42428b427 (diff) | |
download | tcl-d31b1fb794a7d6495a9f02424a6bd82cd8f97d70.zip tcl-d31b1fb794a7d6495a9f02424a6bd82cd8f97d70.tar.gz tcl-d31b1fb794a7d6495a9f02424a6bd82cd8f97d70.tar.bz2 |
2001-07-18 Andreas Kupries <andreas_kupries@users.sourceforge.net>
* generic/tclIO.c: Aftermath to [SF #427196]. Squash empty buffers
if they are smaller than the requested buffersize, to prevent
reusage of old buffers and to honor changes in the requested
buffersize made by the user.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tclIO.c | 26 |
2 files changed, 32 insertions, 1 deletions
@@ -1,3 +1,10 @@ +2001-07-18 Andreas Kupries <andreas_kupries@users.sourceforge.net> + + * generic/tclIO.c: Aftermath to [SF #427196]. Squash empty buffers + if they are smaller than the requested buffersize, to prevent + reusage of old buffers and to honor changes in the requested + buffersize made by the user. + 2001-07-17 Andreas Kupries <andreas_kupries@users.sourceforge.net> * generic/tclIO.c (GetInput): Fixed [SF #427196]. Memory was diff --git a/generic/tclIO.c b/generic/tclIO.c index 815e1a4..2d35e86 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.20.2.7 2001/07/17 20:43:52 hobbs Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.20.2.8 2001/07/18 17:17:19 andreas_kupries Exp $ */ #include "tclInt.h" @@ -1645,6 +1645,17 @@ RecycleBuffer(statePtr, bufPtr, mustDiscard) } /* + * Only save buffers which are at least as big as the requested + * buffersize for the channel. This is to honor dynamic changes + * of the buffersize made by the user. + */ + + if ((bufPtr->bufLength - BUFFER_PADDING) < statePtr->bufSize) { + ckfree((char *) bufPtr); + return; + } + + /* * Only save buffers for the input queue if the channel is readable. */ @@ -4711,6 +4722,19 @@ GetInput(chanPtr) } else { bufPtr = statePtr->saveInBufPtr; statePtr->saveInBufPtr = NULL; + + /* + * Check the actual buffersize against the requested + * buffersize. Buffers which are smaller than requested aare + * squashed. This is done to honor dynamic changes of the + * buffersize made by the user. + */ + + if ((bufPtr != NULL) && ((bufPtr->bufLength - BUFFER_PADDING) < statePtr->bufSize)) { + ckfree((char *) bufPtr); + bufPtr = NULL; + } + if (bufPtr == NULL) { bufPtr = AllocChannelBuffer(statePtr->bufSize); } |