summaryrefslogtreecommitdiff
path: root/send-utils.c
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2013-04-09 19:08:33 +0200
committerDavid Sterba <dsterba@suse.cz>2013-04-23 18:56:22 +0200
commit9b1daecf178bb7ff5be6e774853865080b721aac (patch)
treef7fafddcdfb3b8bc5819aa4d523afd43e70a8249 /send-utils.c
parenta3ed81c5e93079cfe8100382e6e015fba76a7715 (diff)
Btrfs-progs: add a function to free subvol_uuid_search memory
There was no way to free the memory that was used for the subvol_uuid_search functions. Since this is part of the libbtrfs, add such a cleanup function. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Diffstat (limited to 'send-utils.c')
-rw-r--r--send-utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/send-utils.c b/send-utils.c
index b1d3873e..182778a5 100644
--- a/send-utils.c
+++ b/send-utils.c
@@ -304,6 +304,29 @@ out:
return ret;
}
+/*
+ * It's safe to call this function even without the subvol_uuid_search_init()
+ * call before as long as the subvol_uuid_search structure is all-zero.
+ */
+void subvol_uuid_search_finit(struct subvol_uuid_search *s)
+{
+ struct rb_root *root = &s->root_id_subvols;
+ struct rb_node *node;
+
+ while ((node = rb_first(root))) {
+ struct subvol_info *entry =
+ rb_entry(node, struct subvol_info, rb_root_id_node);
+
+ free(entry->path);
+ rb_erase(node, root);
+ free(entry);
+ }
+
+ s->root_id_subvols = RB_ROOT;
+ s->local_subvols = RB_ROOT;
+ s->received_subvols = RB_ROOT;
+ s->path_subvols = RB_ROOT;
+}
char *path_cat(const char *p1, const char *p2)
{