X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=buffer_tree.c;h=5c884709bab83407fa3f90bcc13bfc1c1b9b7550;hp=7d79636fac717f4e4cb8559dec698f8204eed34c;hb=4ac3134c050ba28b57e0ae9686eb1f6d83e6d586;hpb=49ae9b0afbaa8b1ac05c7956f325c4f7a710b59a diff --git a/buffer_tree.c b/buffer_tree.c index 7d79636f..5c884709 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -729,44 +729,37 @@ void btr_drain(struct btr_node *btrn) 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; } /**