int variant_rm(struct variant *variant) { /* Just disable the variant and remove it from the structures, since * some tup_entrys may already point to us. */ variant->enabled = 0; tupid_tree_rm(&variant_dt_root, &variant->dtnode); tupid_tree_rm(&variant_root, &variant->tnode); LIST_REMOVE(variant, list); vardb_close(&variant->vdb); LIST_INSERT_HEAD(&disabled_list, variant, list); return 0; }
void variants_free(void) { struct variant *variant; while(!LIST_EMPTY(&variant_list)) { variant = LIST_FIRST(&variant_list); tupid_tree_rm(&variant_dt_root, &variant->dtnode); tupid_tree_rm(&variant_root, &variant->tnode); LIST_REMOVE(variant, list); vardb_close(&variant->vdb); free(variant); } while(!LIST_EMPTY(&disabled_list)) { variant = LIST_FIRST(&disabled_list); LIST_REMOVE(variant, list); free(variant); } }
void free_tupid_tree(struct tupid_entries *root) { struct tupid_tree *tt; while((tt = RB_ROOT(root)) != NULL) { tupid_tree_rm(root, tt); free(tt); } }
void tupid_tree_remove(struct tupid_entries *root, tupid_t tupid) { struct tupid_tree *tt; tt = tupid_tree_search(root, tupid); if(!tt) { return; } tupid_tree_rm(root, tt); free(tt); }
void tree_entry_remove(struct tupid_entries *root, tupid_t tupid, int *count) { struct tree_entry *te; struct tupid_tree *tt; tt = tupid_tree_search(root, tupid); if(!tt) return; tupid_tree_rm(root, tt); te = container_of(tt, struct tree_entry, tnode); if(count) (*count)--; free(te); }
void dircache_del(struct dircache_root *droot, struct dircache *dc) { tupid_tree_rm(&droot->wd_root, &dc->wd_node); tupid_tree_rm(&droot->dt_root, &dc->dt_node); free(dc); }