summaryrefslogtreecommitdiff
path: root/btrfs-list.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-07-03 21:25:13 +0800
committerChris Mason <chris.mason@fusionio.com>2013-07-03 14:06:54 -0400
commitd35300269709a0588b3252373c70eb94df7520fe (patch)
tree23d456e3f13677ff0dadb16848cdd67d3a55fe44 /btrfs-list.c
parent615f2867854c186a37cb2e2e5a2e13e9ed4ab0df (diff)
Btrfs-progs: introduce common insert/search/delete functions for rb-tree
In fact, the code of many rb-tree insert/search/delete functions is similar, so we can abstract them, and implement common functions for rb-tree, and then simplify them. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'btrfs-list.c')
-rw-r--r--btrfs-list.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/btrfs-list.c b/btrfs-list.c
index c3d35de3..4fab8588 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -513,8 +513,11 @@ static int add_root(struct root_lookup *root_lookup,
return 0;
}
-void __free_root_info(struct root_info *ri)
+static void __free_root_info(struct rb_node *node)
{
+ struct root_info *ri;
+
+ ri = rb_entry(node, struct root_info, rb_node);
if (ri->name)
free(ri->name);
@@ -527,19 +530,9 @@ void __free_root_info(struct root_info *ri)
free(ri);
}
-void __free_all_subvolumn(struct root_lookup *root_tree)
+static inline void __free_all_subvolumn(struct root_lookup *root_tree)
{
- struct root_info *entry;
- struct rb_node *n;
-
- n = rb_first(&root_tree->root);
- while (n) {
- entry = rb_entry(n, struct root_info, rb_node);
- rb_erase(n, &root_tree->root);
- __free_root_info(entry);
-
- n = rb_first(&root_tree->root);
- }
+ rb_free_nodes(&root_tree->root, __free_root_info);
}
/*