@@ -533,15 +533,27 @@ static int add_root_backref(struct root_lookup *root_lookup, u64 root_id,
name_len, 0, 0, 0, NULL, NULL, NULL);
}
+static void __btrfs_free_root_info_strings(struct root_info *ri)
+{
+ free(ri->name);
+ free(ri->path);
+ free(ri->full_path);
+}
+
+void btrfs_cleanup_root_info(struct root_info *ri)
+{
+ __btrfs_free_root_info_strings(ri);
+ ri->name = NULL;
+ ri->path = NULL;
+ ri->full_path = NULL;
+}
static void free_root_info(struct rb_node *node)
{
struct root_info *ri;
ri = to_root_info(node);
- free(ri->name);
- free(ri->path);
- free(ri->full_path);
+ __btrfs_free_root_info_strings(ri);
free(ri);
}
@@ -176,5 +176,6 @@ char *btrfs_list_path_for_root(int fd, u64 root);
int btrfs_list_get_path_rootid(int fd, u64 *treeid);
int btrfs_get_subvol(int fd, struct root_info *the_ri);
int btrfs_get_toplevel_subvol(int fd, struct root_info *the_ri);
+void btrfs_cleanup_root_info(struct root_info *ri);
#endif
@@ -1113,10 +1113,7 @@ static int cmd_subvol_show(int argc, char **argv)
1, raw_prefix);
out:
- /* clean up */
- free(get_ri.path);
- free(get_ri.name);
- free(get_ri.full_path);
+ btrfs_cleanup_root_info(&get_ri);
free(filter_set);
close_file_or_dir(fd, dirstream1);