Commit
072391fc (Improve btr_splice_out_node(), 2013-03) modified this
function to take a pointer to a buffer tree node pointer so that the
node pointer can be invalidated after it is spliced out. However, this
also means the caller can no longer free its resources. Hence we must
free the btrn in btr_splice_out_node() in order to avoid memory leaks.
btr_drop_buffer_reference(br);
}
+static void btr_free_node(struct btr_node *btrn)
+{
+ free(btrn->name);
+ free(btrn);
+}
+
/**
* Remove a node from a buffer tree.
*
btr_drain(btrn);
if (btrn->parent)
list_del(&btrn->node);
- free(btrn->name);
- free(btrn);
+ btr_free_node(btrn);
out:
*btrnp = NULL;
}
list_del(&ch->node);
}
assert(list_empty(&btrn->children));
+ btr_free_node(btrn);
*btrnp = NULL;
}