mirror of
https://github.com/corda/corda.git
synced 2025-01-21 20:08:27 +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
|
object
|
||||||
treeFind(Thread* t, object oldRoot, object node, object sentinal)
|
treeFind(Thread* t, object old, object node, object sentinal)
|
||||||
{
|
{
|
||||||
object newRoot = clone(t, oldRoot);
|
PROTECT(t, old);
|
||||||
object ancestors = 0;
|
PROTECT(t, node);
|
||||||
|
PROTECT(t, sentinal);
|
||||||
|
|
||||||
|
object newRoot = clone(t, old);
|
||||||
|
PROTECT(t, newRoot);
|
||||||
|
|
||||||
object old = oldRoot;
|
|
||||||
object new_ = newRoot;
|
object new_ = newRoot;
|
||||||
|
PROTECT(t, new_);
|
||||||
|
|
||||||
|
object ancestors = 0;
|
||||||
|
PROTECT(t, ancestors);
|
||||||
|
|
||||||
while (old != sentinal) {
|
while (old != sentinal) {
|
||||||
ancestors = makePair(t, new_, ancestors);
|
ancestors = makePair(t, new_, ancestors);
|
||||||
|
|
||||||
@ -82,8 +90,13 @@ object
|
|||||||
treeAdd(Thread* t, object path)
|
treeAdd(Thread* t, object path)
|
||||||
{
|
{
|
||||||
object new_ = treePathNode(t, path);
|
object new_ = treePathNode(t, path);
|
||||||
|
PROTECT(t, new_);
|
||||||
|
|
||||||
object newRoot = treePathRoot(t, path);
|
object newRoot = treePathRoot(t, path);
|
||||||
|
PROTECT(t, newRoot);
|
||||||
|
|
||||||
object ancestors = treePathAncestors(t, path);
|
object ancestors = treePathAncestors(t, path);
|
||||||
|
PROTECT(t, ancestors);
|
||||||
|
|
||||||
// rebalance
|
// rebalance
|
||||||
treeNodeRed(t, new_) = true;
|
treeNodeRed(t, new_) = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user