btr_drop_buffer_reference(br);
}
-/**
- * Free all resources allocated by btr_new_node().
- *
- * \param btrn Pointer to a btr node obtained by \ref btr_new_node().
- *
- * Like free(3), it is OK to call this with a \p NULL pointer argument.
- */
-void btr_free_node(struct btr_node *btrn)
-{
- if (!btrn)
- return;
- free(btrn->name);
- free(btrn);
-}
-
/**
* Remove a node from a buffer tree.
*
- * \param btrn The node to remove.
+ * \param btrnp Determines the node to remove.
*
- * This makes all child nodes of \a btrn orphans and removes \a btrn from the
- * list of children of its parent. Moreover, the input queue of \a btrn is
- * flushed if it is not empty.
+ * This orphans all children of the node given by \a btrnp and removes this
+ * node from the child list of its parent. Moreover, the input queue is flushed
+ * and the node pointer given by \a btrp is set to \p NULL.
*
* \sa \ref btr_splice_out_node.
*/
-void btr_remove_node(struct btr_node *btrn)
+void btr_remove_node(struct btr_node **btrnp)
{
struct btr_node *ch;
+ struct btr_node *btrn;
- if (!btrn)
+ if (!btrnp)
return;
+ btrn = *btrnp;
+ if (!btrn)
+ goto out;
PARA_INFO_LOG("removing btr node %s from buffer tree\n", btrn->name);
FOR_EACH_CHILD(ch, btrn)
ch->parent = NULL;
btr_drain(btrn);
if (btrn->parent)
list_del(&btrn->node);
+ free(btrn->name);
+ free(btrn);
+out:
+ *btrnp = NULL;
}
/**