From 6cc38d5ff36cfbb941affae49796516273ec66a7 Mon Sep 17 00:00:00 2001 From: andreas_kupries Date: Wed, 18 Jul 2001 17:13:25 +0000 Subject: 2001-07-18 Andreas Kupries * 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. --- ChangeLog | 7 +++++++ generic/tclIO.c | 26 +++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 079bd62..e0e03fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-07-18 Andreas Kupries + + * 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 Mo DeJong * win/tclWinFile.c (TclpReadlink): Add Cygwin specific definition 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); } -- cgit v0.12