static MuContainer* prune_empty_containers (MuContainer *root_set) { MuContainer *cur; mu_container_foreach (root_set, (MuContainerForeachFunc)prune_maybe, NULL); /* and prune the root_set itself... */ for (cur = root_set; cur; cur = cur->next) { if (cur->flags & MU_CONTAINER_FLAG_DELETE) root_set = mu_container_remove_sibling (root_set, cur); else if (cur->flags & MU_CONTAINER_FLAG_SPLICE) { MuContainer *newchild; newchild = cur->child; cur->child = NULL; root_set = mu_container_append_siblings (root_set, newchild); } } return root_set; }
MuContainer* mu_container_splice_children (MuContainer *c, MuContainer *sibling) { MuContainer *children; g_return_val_if_fail (c, NULL); g_return_val_if_fail (sibling, NULL); children = sibling->child; sibling->child = NULL; return mu_container_append_siblings (c, children); }
static void filter_root_set (const gchar *msgid, MuContainer *c, MuContainer **root_set) { /* ignore children */ if (c->parent) return; /* ignore duplicates */ if (c->flags & MU_CONTAINER_FLAG_DUP) return; if (*root_set == NULL) { *root_set = c; return; } else *root_set = mu_container_append_siblings (*root_set, c); }
MuContainer* mu_container_append_children (MuContainer *c, MuContainer *child) { g_return_val_if_fail (c, NULL); g_return_val_if_fail (child, NULL); g_return_val_if_fail (c != child, NULL); /* assert_no_duplicates (c); */ set_parent (child, c); if (!c->child) c->child = child; else c->child = mu_container_append_siblings (c->child, child); /* assert_no_duplicates (c->child); */ return c; }