summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvasiljevic <zv@archiware.com>2007-06-30 09:59:00 (GMT)
committervasiljevic <zv@archiware.com>2007-06-30 09:59:00 (GMT)
commit22f41058c511758b0e8085d4518b7c32a1d932c9 (patch)
tree7ef1fc750222e510edb6d07daba1b21d72ce954e /generic
parentf491ae44dd5eeb9e80d673810c8a46faa0d0a3aa (diff)
downloadtcl-22f41058c511758b0e8085d4518b7c32a1d932c9.zip
tcl-22f41058c511758b0e8085d4518b7c32a1d932c9.tar.gz
tcl-22f41058c511758b0e8085d4518b7c32a1d932c9.tar.bz2
Prevent RemeberSyncObj() from growing the sync
object lists by reusing already free'd slots, if possible. See discussion on Bug 1726873 for more information.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclThread.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c
index 60c09ca..9732a4f 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclThread.c,v 1.16 2007/05/01 22:43:50 kennykb Exp $
+ * RCS: @(#) $Id: tclThread.c,v 1.17 2007/06/30 09:59:00 vasiljevic Exp $
*/
#include "tclInt.h"
@@ -159,10 +159,21 @@ RememberSyncObject(
char **newList;
int i, j;
+
/*
- * Save the pointer to the allocated object so it can be finalized. Grow
- * the list of pointers if necessary, copying only non-NULL pointers to
- * the new list.
+ * Reuse any free slot in the list.
+ */
+
+ for (i=0 ; i < recPtr->num ; ++i) {
+ if (recPtr->list[i] == NULL) {
+ recPtr->list[i] = objPtr;
+ return;
+ }
+ }
+
+ /*
+ * Grow the list of pointers if necessary, copying only non-NULL
+ * pointers to the new list.
*/
if (recPtr->num >= recPtr->max) {
@@ -179,6 +190,7 @@ RememberSyncObject(
recPtr->list = newList;
recPtr->num = j;
}
+
recPtr->list[recPtr->num] = objPtr;
recPtr->num++;
}