summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclThread.c20
2 files changed, 22 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d834f9e..60355f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-06-30 Zoran Vasiljevic <vasiljevic@users.sourceforge.net>
+
+ * generic/tclThread.c: Prevent RemeberSyncObj() from growing the sync
+ object lists by reusing already free'd slots, if possible.
+ See discussion on Bug 1726873 for more information.
+
2007-06-29 Donal K. Fellows <dkf@users.sf.net>
* doc/DictObj.3 (Tcl_DictObjDone): Improved documentation of this
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++;
}