[svn] commit: r3473 - in /branches/trac397/src/bin/auth: rbt_datasrc.cc rbt_datasrc.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Nov 6 05:57:14 UTC 2010
Author: hanfeng
Date: Sat Nov 6 05:57:14 2010
New Revision: 3473
Log:
modify &/* according to code guideline
Modified:
branches/trac397/src/bin/auth/rbt_datasrc.cc
branches/trac397/src/bin/auth/rbt_datasrc.h
Modified: branches/trac397/src/bin/auth/rbt_datasrc.cc
==============================================================================
--- branches/trac397/src/bin/auth/rbt_datasrc.cc (original)
+++ branches/trac397/src/bin/auth/rbt_datasrc.cc Sat Nov 6 05:57:14 2010
@@ -22,14 +22,14 @@
namespace {
/// helper function to remove the base domain from super domain
/// the precondition of this function is thant super_name contains sub_name
- Name operator-(const Name &super_name, const Name &sub_name) {
+ Name operator-(const Name& super_name, const Name& sub_name) {
return (super_name.split(0, super_name.getLabelCount() - sub_name.getLabelCount()));
}
}
namespace isc {
namespace datasrc {
-RBNode::RBNode(const Name &name, RRsetListPtr rrsets, RBNode * nullnode)
+RBNode::RBNode(const Name& name, RRsetListPtr rrsets, RBNode* nullnode)
: parent_(nullnode),
left_(nullnode),
right_(nullnode),
@@ -78,7 +78,7 @@
}
void
-RBNode::cloneDNSData(RBNode &node) {
+RBNode::cloneDNSData(RBNode& node) {
node.name_ = name_;
node.rrsets_ = rrsets_;
node.is_delegate_ = is_delegate_;
@@ -86,7 +86,7 @@
}
void
-RBNode::setDownTree(RBTree *down) {
+RBNode::setDownTree(RBTree* down) {
down_ = down;
if (down)
down->up_ = this;
@@ -115,7 +115,7 @@
while (node->left_ != NULLNODE || node->right_ != NULLNODE)
node = (node->left_ != NULLNODE) ? node->left_ : node->right_;
- RBNode *parent = node->parent_;
+ RBNode* parent = node->parent_;
if (parent->left_ == node)
parent->left_ = NULLNODE;
else
@@ -129,20 +129,20 @@
}
RBTree::FindResult
-RBTree::find(const Name &name, RBNode **node)const {
- RBTree *tree;
+RBTree::find(const Name& name, RBNode** node)const {
+ RBTree* tree;
return (findHelper(name, &tree, node));
}
RBTree::FindResult
-RBTree::findHelper(const Name &name, RBTree **tree, RBNode **ret)const {
+RBTree::findHelper(const Name& name, RBTree** tree, RBNode** ret)const {
RBNode* node = root_;
while (node != NULLNODE) {
NameComparisonResult compare_result = name.compare(node->name_);
NameComparisonResult::NameRelation relation = compare_result.getRelation();
if (relation == NameComparisonResult::EQUAL) {
- *tree = (RBTree *)this;
+ *tree = (RBTree*)this;
*ret = node;
return (RBTree::EXACTMATCH);
}
@@ -153,42 +153,42 @@
node = (compare_result.getOrder() < 0) ? node->left_ : node->right_;
else if (NameComparisonResult::SUBDOMAIN == relation) {
if (node->isDelegate()) {
- *tree = (RBTree *)this;
+ *tree = (RBTree*)this;
*ret = node;
return (RBTree::FINDREFERRAL);
}
else if (node->down_)
/// the node all save the relative name, so we need to remove the suffix
- return node->down_->findHelper(name - node->name_, tree, ret);
+ return (node->down_->findHelper(name - node->name_, tree, ret));
else
- return RBTree::NOTFOUND;
+ return (RBTree::NOTFOUND);
}
else
- return RBTree::NOTFOUND;
+ return (RBTree::NOTFOUND);
}
}
- return RBTree::NOTFOUND;
+ return (RBTree::NOTFOUND);
}
int
RBTree::getNodeCount() const {
- return getNodeCountHelper(root_);
+ return (getNodeCountHelper(root_));
}
int
RBTree::getNodeCountHelper(const RBNode *node) const {
if (NULLNODE == node)
- return 0;
+ return (0);
int sub_tree_node_count = node->down_ ? node->down_->getNodeCount() : 0;
- return 1 + sub_tree_node_count + getNodeCountHelper(node->left_) + getNodeCountHelper(node->right_);
+ return (1 + sub_tree_node_count + getNodeCountHelper(node->left_) + getNodeCountHelper(node->right_));
}
int
-RBTree::insert(const Name &name, RBNode **new_node) {
+RBTree::insert(const Name& name, RBNode** new_node) {
RBNode* parent = NULLNODE;
RBNode* current = root_;
@@ -202,7 +202,7 @@
if (new_node)
*new_node = current;
/// if the node is non-ternimal, it doesn't exist, so we return 0
- return current->rrsets_.get() ? 1 : 0;
+ return (current->rrsets_.get() ? 1 : 0);
}
else {
int common_label_count = compare_result.getCommonLabels();
@@ -214,16 +214,16 @@
if (relation == NameComparisonResult::SUBDOMAIN) {
if (NULL == current->down_)
current->setDownTree(new RBTree());
- return current->down_->insert(name - current->name_, new_node);
+ return (current->down_->insert(name - current->name_, new_node));
} else {
// for super domain or has common label domain, create common node first
// then insert current name and new name into the sub tree
Name common_ancestor = name.split(name.getLabelCount() - common_label_count, common_label_count);
Name sub_name = current->name_ - common_ancestor;
current->name_ = common_ancestor;
- RBTree *down_old = current->down_;
+ RBTree* down_old = current->down_;
current->setDownTree(new RBTree());
- RBNode *sub_root;
+ RBNode* sub_root;
current->down_->insert(sub_name, &sub_root);
current->cloneDNSData(*sub_root);
@@ -235,10 +235,10 @@
//otherwise insert it into the down tree
if (name.getLabelCount() == common_label_count) {
*new_node = current;
- return 0;
+ return (0);
} else {
current->is_nonterminal_ = true;
- return current->down_->insert(name - common_ancestor, new_node);
+ return (current->down_->insert(name - common_ancestor, new_node));
}
}
}
@@ -259,11 +259,11 @@
if (new_node)
*new_node = node;
++node_count_;
- return 0;
-}
-
-void
-RBTree::insertRebalance(RBNode * node) {
+ return (0);
+}
+
+void
+RBTree::insertRebalance(RBNode* node) {
RBNode* uncle;
while (node->parent_->color_ == RED) {
@@ -314,7 +314,7 @@
RBNode*
-RBTree::leftRotate(RBNode * p) {
+RBTree::leftRotate(RBNode* p) {
RBNode* c = p->right_;
p->right_ = c->left_;
@@ -334,11 +334,11 @@
c->left_ = p;
p->parent_ = c;
- return c;
+ return (c);
}
RBNode*
-RBTree::rightRotate(RBNode * p) {
+RBTree::rightRotate(RBNode* p) {
RBNode* c = p->left_;
p->left_ = c->right_;
@@ -358,25 +358,25 @@
c->right_ = p;
p->parent_ = c;
- return c;
+ return (c);
}
int
-RBTree::erase(const Name &name) {
- RBNode *node;
- RBTree *tree;
+RBTree::erase(const Name& name) {
+ RBNode* node;
+ RBTree* tree;
if (findHelper(name, &tree, &node) != RBTree::EXACTMATCH)
- return 1;
+ return (1);
/// cann't delete non terminal
if (node->down_ != NULL)
- return 1;
+ return (1);
tree->eraseNode(node);
///merge down to up
if (tree->node_count_ == 1 && tree->up_ != NULL && tree->up_->isNonterminal()) {
- RBNode *up = tree->up_;
+ RBNode* up = tree->up_;
Name merged_name = tree->root_->name_.concatenate(up->name_);
tree->root_->cloneDNSData(*up);
up->setDownTree(tree->root_->down_);
@@ -389,7 +389,7 @@
delete tree;
}
- return 0;
+ return (0);
}
@@ -437,7 +437,7 @@
}
void
-RBTree::deleteRebalance(RBNode * node) {
+RBTree::deleteRebalance(RBNode* node) {
RBNode* w = NULLNODE;
while (node != root_ && node->color_ == BLACK) {
@@ -513,7 +513,7 @@
void
-RBTree::printTreeHelper(RBNode *node, int depth) const {
+RBTree::printTreeHelper(RBNode* node, int depth) const {
INDNET(depth);
std::cout << node->name_.toText() << " (" << ((node->color_ == BLACK) ? "black" : "red") << ")\n";
Modified: branches/trac397/src/bin/auth/rbt_datasrc.h
==============================================================================
--- branches/trac397/src/bin/auth/rbt_datasrc.h (original)
+++ branches/trac397/src/bin/auth/rbt_datasrc.h Sat Nov 6 05:57:14 2010
@@ -51,24 +51,24 @@
const Name &getName() const {return name_;}
//next domain name which is bigger than current one
- RBNode * successor();
+ RBNode* successor();
private:
- RBNode(const Name &name, RRsetListPtr rrsets = RRsetListPtr(), RBNode* nullnode = NULL);
+ RBNode(const Name& name, RRsetListPtr rrsets = RRsetListPtr(), RBNode* nullnode = NULL);
~RBNode(); //the class isn't left to be inherited
- void cloneDNSData(RBNode &node);
- void setDownTree(RBTree *down);
+ void cloneDNSData(RBNode& node);
+ void setDownTree(RBTree* down);
/// data to maintain the rbtree balance
- RBNode * parent_;
- RBNode * left_;
- RBNode * right_;
+ RBNode* parent_;
+ RBNode* left_;
+ RBNode* right_;
int color_;
/// data to carry dns info
Name name_;
RRsetListPtr rrsets_;
- RBTree * down_;
+ RBTree* down_;
bool is_delegate_;
bool is_nonterminal_;
};
@@ -88,7 +88,7 @@
/// if find result isn't NOTFOUND, the node will point to the result
/// with return value equal to NOTFOUND, the value of node is undetermined
- FindResult find(const Name &name, RBNode **node)const;
+ FindResult find(const Name& name, RBNode** node)const;
/// get all the node count recursively, including the sub trees
/// note that the return value isn't same with valid domain names in the tree
@@ -101,28 +101,28 @@
/// if the name exists, return value will be one, and inserted_node will point to
/// the existed node, otherwise return value is zero, and inserted_node points to
/// new created node
- int insert(const Name &name, RBNode **inserted_node);
+ int insert(const Name& name, RBNode** inserted_node);
/// if the node doesn't exist, return value will be one otherwise zero
- int erase(const Name &name);
+ int erase(const Name& name);
private:
void deleteRebalance(RBNode* node);
void insertRebalance(RBNode* node);
- RBNode * rightRotate(RBNode* p);
- RBNode * leftRotate(RBNode* p);
- void printTreeHelper(RBNode *node, int depth)const;
- void eraseNode(RBNode *node);
+ RBNode* rightRotate(RBNode* p);
+ RBNode* leftRotate(RBNode* p);
+ void printTreeHelper(RBNode* node, int depth)const;
+ void eraseNode(RBNode* node);
/// recursive find one name in the tree, and return the exact tree has the name
- FindResult findHelper(const Name &name, RBTree **tree, RBNode **node)const;
- int getNodeCountHelper(const RBNode *node) const;
+ FindResult findHelper(const Name& name, RBTree** tree, RBNode** node)const;
+ int getNodeCountHelper(const RBNode* node) const;
void setUpNode(RBNode *node);
- RBNode * root_;
- RBNode * NULLNODE;
- RBNode * up_;
+ RBNode* root_;
+ RBNode* NULLNODE;
+ RBNode* up_;
unsigned int node_count_; //current tree node count exclude the node in down pointing trees
};
}
More information about the bind10-changes
mailing list