Commit d0b73dfd authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

refactored nodeFission() a bit so that it would be consistent with the

documentation regarding exceptin guarantee.
parent 4d42a76c
......@@ -738,10 +738,13 @@ RBTree<T>::nodeFission(RBNode<T>& node, const isc::dns::Name& base_name) {
// using auto_ptr here is to avoid memory leak in case of exceptoin raised
// after the RBNode creation
std::auto_ptr<RBNode<T> > down_node(new RBNode<T>(sub_name));
node.name_ = base_name;
// the rest of this function should be exception free so that it keeps
// consistent behavior (i.e., a weak form of strong exception guarantee)
// even if code after the call to this function throws an exception.
std::swap(node.data_, down_node->data_);
std::swap(node.callback_required_, down_node->callback_required_);
down_node->down_ = node.down_;
node.name_ = base_name;
node.down_ = down_node.get();
//root node of sub tree, the initial color is BLACK
down_node->color_ = RBNode<T>::BLACK;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment