protect local variables in red-black tree implementation from GC

This commit is contained in:
Joel Dice 2007-11-27 08:46:31 -07:00
parent 466c958d2b
commit 6ac124f2fb

View File

@ -19,13 +19,21 @@ clone(Thread* t, object o)
}
object
treeFind(Thread* t, object oldRoot, object node, object sentinal)
treeFind(Thread* t, object old, object node, object sentinal)
{
object newRoot = clone(t, oldRoot);
object ancestors = 0;
PROTECT(t, old);
PROTECT(t, node);
PROTECT(t, sentinal);
object newRoot = clone(t, old);
PROTECT(t, newRoot);
object old = oldRoot;
object new_ = newRoot;
PROTECT(t, new_);
object ancestors = 0;
PROTECT(t, ancestors);
while (old != sentinal) {
ancestors = makePair(t, new_, ancestors);
@ -82,8 +90,13 @@ object
treeAdd(Thread* t, object path)
{
object new_ = treePathNode(t, path);
PROTECT(t, new_);
object newRoot = treePathRoot(t, path);
PROTECT(t, newRoot);
object ancestors = treePathAncestors(t, path);
PROTECT(t, ancestors);
// rebalance
treeNodeRed(t, new_) = true;