Skip to content
Tcl Source Code Attachment Details
Login

Attachment Details

Overview

Artifact ID: cc0c1d59e93567715c483707238501a7d9e0653a
Ticket: 427196ffffffffffffffffffffffffffffffffff
Date: 2001-07-18 04:11:23
User: andreas_kupries
Artifact Attached: 4fa0950818f5b52b124b32145a18bb0b1fc3f512
Filename:tcl.427196.2.diff.txt
Description:Patch, performance enhancement
Content:
? tools/man2tcl
? unix/LOG
? unix/LOG.2
? unix/linux-static
? unix/linux-static2
? unix/linux-debug
? unix/linux-ix86
? unix/buffer.tcl
Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.31
diff -u -r1.31 tclIO.c
--- generic/tclIO.c	2001/07/17 17:53:43	1.31
+++ generic/tclIO.c	2001/07/17 21:08:10
@@ -1701,6 +1701,17 @@
     }
 
     /*
+     * 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 @@
     } 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);
 	}