[sheepdog] [PATCH v2 2/6] use rb_destory to clean up rbtree

MORITA Kazutaka morita.kazutaka at gmail.com
Tue Sep 24 11:08:11 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 dog/farm/object_tree.c | 7 +------
 sheep/vdi.c            | 7 +------
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/dog/farm/object_tree.c b/dog/farm/object_tree.c
index 28cd4e6..c624fea 100644
--- a/dog/farm/object_tree.c
+++ b/dog/farm/object_tree.c
@@ -71,12 +71,7 @@ void object_tree_print(void)
 
 void object_tree_free(void)
 {
-	struct object_tree_entry *entry;
-	rb_for_each_entry(entry, &tree.root, node) {
-		rb_erase(&entry->node, &tree.root);
-		free(entry);
-	}
-
+	rb_destroy(&tree.root, struct object_tree_entry, node);
 	free(cached_entry);
 }
 
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 0faab62..e46e3e7 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -1104,13 +1104,8 @@ out:
 
 void clean_vdi_state(void)
 {
-	struct vdi_state_entry *entry;
-
 	sd_write_lock(&vdi_state_lock);
-	rb_for_each_entry(entry, &vdi_state_root, node) {
-		rb_erase(&entry->node, &vdi_state_root);
-		free(entry);
-	}
+	rb_destroy(&vdi_state_root, struct vdi_state_entry, node);
 	INIT_RB_ROOT(&vdi_state_root);
 	sd_unlock(&vdi_state_lock);
 }
-- 
1.8.1.2




More information about the sheepdog mailing list