From: Andre Noll Date: Tue, 29 Dec 2009 21:53:07 +0000 (+0100) Subject: buffer_tree: Add code to splice out a node of the buffer tree. X-Git-Tag: v0.4.2~240 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=5587494468627e20fe622b6055689717262d09ab;hp=c6675d53d29b87bf0ac4c713edbaae630611048e buffer_tree: Add code to splice out a node of the buffer tree. --- diff --git a/buffer_tree.c b/buffer_tree.c index 2a52f097..92566745 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -216,6 +216,24 @@ size_t btr_get_input_queue_size(struct btr_node *btrn) return size; } +int btr_splice_out_node(struct btr_node *btrn) +{ + struct btr_node *ch; + + if (!btrn) + return -ERRNO_TO_PARA_ERROR(EINVAL); + if (btr_get_input_queue_size(btrn) != 0) + return -ERRNO_TO_PARA_ERROR(EINVAL); + PARA_NOTICE_LOG("splicing out %s\n", btrn->name); + if (btrn->parent) + list_del(&btrn->node); + FOR_EACH_CHILD(ch, btrn) + ch->parent = btrn->parent; + free(btrn->name); + free(btrn); + return 1; +} + /** * Return the size of the largest input queue. * diff --git a/buffer_tree.h b/buffer_tree.h index c84a9305..69886c79 100644 --- a/buffer_tree.h +++ b/buffer_tree.h @@ -15,3 +15,4 @@ size_t btr_next_buffer(struct btr_node *btrn, char **bufp); void btr_consume(struct btr_node *btrn, size_t numbytes); int btr_exec(struct btr_node *btrn, const char *command, char **value_result); int btr_exec_up(struct btr_node *btrn, const char *command, char **value_result); +int btr_splice_out_node(struct btr_node *btrn);