diff options
-rw-r--r-- | src/tree.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -181,8 +181,32 @@ mq_tree_append_sibling_allocated(MqTree *node, MqTree *sibling, gpointer data) void mq_tree_remove_allocated(MqTree *node) { - /* TODO */ - node = node; + MqTree *child; + + /* Link previous sibling or parent to children. */ + if (node->prev) { + node->prev->next = node->first_child; + } else { + node->parent->first_child = node->first_child; + if (!node->next) { + node->parent->last_child = node->last_child; + } + } + + /* Link children to siblings (may be NULL). */ + if (node->first_child) { + node->first_child->prev = node->prev; + } + if (node->last_child) { + node->last_child->next = node->next; + } + + /* Link children to parent. */ + for (child = node->first_child; child; child = child->next) { + child->parent = node->parent; + } + + update_positions(node, -1); } MqTree * |