mirror of
https://github.com/corda/corda.git
synced 2025-01-21 12:05:08 +00:00
protect local variables in red-black tree implementation from GC
This commit is contained in:
parent
466c958d2b
commit
6ac124f2fb
21
src/util.cpp
21
src/util.cpp
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user