diff --git a/xo-allocutil/include/xo/allocutil/IAlloc.hpp b/xo-allocutil/include/xo/allocutil/IAlloc.hpp index 703e968c..2c78b131 100644 --- a/xo-allocutil/include/xo/allocutil/IAlloc.hpp +++ b/xo-allocutil/include/xo/allocutil/IAlloc.hpp @@ -140,6 +140,12 @@ namespace xo { * in-progress collection phase **/ virtual bool check_move(IObject * /*src*/) const { return false; } + /** check write barrier (if impl has write barrier) + * given an object @p parent that contains object pointer @p lhs. + **/ + virtual bool check_write_barrier(IObject * /*parent*/, + IObject ** /*lhs*/, + bool /*may_throw*/) const { return true; }; /** write barrier for collector. perform assignment * @code * *lhs = rhs diff --git a/xo-ordinaltree/include/xo/ordinaltree/RedBlackTree.hpp b/xo-ordinaltree/include/xo/ordinaltree/RedBlackTree.hpp index 6e1fba07..78b1555b 100644 --- a/xo-ordinaltree/include/xo/ordinaltree/RedBlackTree.hpp +++ b/xo-ordinaltree/include/xo/ordinaltree/RedBlackTree.hpp @@ -534,15 +534,26 @@ namespace xo { log("pre", xtag("key", key), xtag("tree", *this)); } + RbNode * adj_root = this->root_; + bool retval = RbUtil::erase_aux(this->node_alloc_, key, this->reduce_fn_, debug_flag_, - &(this->root_)); + &adj_root); - if (retval) + if (retval) { --(this->size_); + if (adj_root != root_) { + allocator_type alloc = node_alloc_; + + this->_gc_assign_member(&(this->root_), adj_root, alloc); + } + } else { + assert(adj_root == root_); + } + if (log) { log("post", xtag("tree", *this)); } diff --git a/xo-ordinaltree/include/xo/ordinaltree/rbtree/Node.hpp b/xo-ordinaltree/include/xo/ordinaltree/rbtree/Node.hpp index 27048041..f568c92c 100644 --- a/xo-ordinaltree/include/xo/ordinaltree/rbtree/Node.hpp +++ b/xo-ordinaltree/include/xo/ordinaltree/rbtree/Node.hpp @@ -266,8 +266,8 @@ namespace xo { /* true if this node is red, and either child is red */ bool is_red_violation() const { if (this->color_ == C_Red) { - Node *left = this->left_child(); - Node *right = this->right_child(); + Node * left = this->left_child(); + Node * right = this->right_child(); if (left && left->is_red()) return true; @@ -455,7 +455,7 @@ namespace xo { */ std::pair reduced_; /* pointer to parent node, nullptr iff this is the root node */ - Node *parent_ = nullptr; + Node * parent_ = nullptr; /* * .child_v[0] = left child * .child_v[1] = right child diff --git a/xo-ordinaltree/include/xo/ordinaltree/rbtree/RbTreeUtil.hpp b/xo-ordinaltree/include/xo/ordinaltree/rbtree/RbTreeUtil.hpp index 0545965a..f263b7b4 100644 --- a/xo-ordinaltree/include/xo/ordinaltree/rbtree/RbTreeUtil.hpp +++ b/xo-ordinaltree/include/xo/ordinaltree/rbtree/RbTreeUtil.hpp @@ -317,7 +317,7 @@ namespace xo { */ static RbNode * find_rightmost(RbNode *N) { while(N) { - RbNode *S = N->right_child(); + RbNode * S = N->right_child(); if (!S) break; @@ -417,7 +417,7 @@ namespace xo { return x; } - RbNode *y = find_lub(x->left_child(), k, is_closed); + RbNode * y = find_lub(x->left_child(), k, is_closed); if (y) { /* found better upper bound in left subtree */ @@ -911,7 +911,7 @@ namespace xo { assert(pp_root); - RbNode *P = N->parent(); + RbNode * P = N->parent(); if (!P) { /* N was the root node, tree now empty */ @@ -948,9 +948,9 @@ namespace xo { * C D */ Direction other_d; - RbNode *S = nullptr; - RbNode *C = nullptr; - RbNode *D = nullptr; + RbNode * S = nullptr; + RbNode * C = nullptr; + RbNode * D = nullptr; /* table of outcomes as a function of node color *