diff options
author | vasiljevic <vasiljevic@noemail.net> | 2007-06-30 09:58:59 (GMT) |
---|---|---|
committer | vasiljevic <vasiljevic@noemail.net> | 2007-06-30 09:58:59 (GMT) |
commit | 98655b002449b0490f08b54521fa0088e1509db7 (patch) | |
tree | 7ef1fc750222e510edb6d07daba1b21d72ce954e /generic/tclThread.c | |
parent | 7904675ac73381bdaa061ec7add948a41a714bf0 (diff) | |
download | tcl-98655b002449b0490f08b54521fa0088e1509db7.zip tcl-98655b002449b0490f08b54521fa0088e1509db7.tar.gz tcl-98655b002449b0490f08b54521fa0088e1509db7.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.
FossilOrigin-Name: 41d4c04c241d5bb39d03d0c6eafa5edb7eb73705
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r-- | generic/tclThread.c | 20 |
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++; } |