diff options
author | andreas_kupries <andreas_kupries@noemail.net> | 2001-07-18 17:13:24 (GMT) |
---|---|---|
committer | andreas_kupries <andreas_kupries@noemail.net> | 2001-07-18 17:13:24 (GMT) |
commit | 0083a26b852639e15164a868ffa8c67dd3461c75 (patch) | |
tree | 75f253f099ade98f7839e25cc46fd31bd08f1c04 /generic/tclIO.c | |
parent | 2c71efcf135bfd628701f1362d098d2f5bd22765 (diff) | |
download | tcl-0083a26b852639e15164a868ffa8c67dd3461c75.zip tcl-0083a26b852639e15164a868ffa8c67dd3461c75.tar.gz tcl-0083a26b852639e15164a868ffa8c67dd3461c75.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.
FossilOrigin-Name: f732d07f7943bce22d508ef1151dfe1a67478fb7
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index fe233ad..7bd0938 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.31 2001/07/17 17:53:43 andreas_kupries Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.32 2001/07/18 17:13:25 andreas_kupries Exp $ */ #include "tclInt.h" @@ -1701,6 +1701,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. */ @@ -4994,6 +5005,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); } |