int cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) { struct args *args = self->args; struct key_binding *bd; int key; if (args_has(args, 'a')) { while (!SPLAY_EMPTY(&key_bindings)) { bd = SPLAY_ROOT(&key_bindings); SPLAY_REMOVE(key_bindings, &key_bindings, bd); cmd_list_free(bd->cmdlist); xfree(bd); } return (0); } key = key_string_lookup_string(args->argv[0]); if (key == KEYC_NONE) { ctx->error(ctx, "unknown key: %s", args->argv[0]); return (-1); } if (args_has(args, 't')) return (cmd_unbind_key_table(self, ctx, key)); if (!args_has(args, 'n')) key |= KEYC_PREFIX; key_bindings_remove(key); return (0); }
void key_bindings_clean(void) { struct key_binding *bd; while (!SPLAY_EMPTY(&dead_key_bindings)) { bd = SPLAY_ROOT(&dead_key_bindings); SPLAY_REMOVE(key_bindings, &dead_key_bindings, bd); cmd_list_free(bd->cmdlist); xfree(bd); } }
void tree_merge(struct tree *dst, struct tree *src) { struct treeentry *entry; while (!SPLAY_EMPTY(src)) { entry = SPLAY_ROOT(src); SPLAY_REMOVE(tree, src, entry); if (SPLAY_INSERT(tree, dst, entry)) errx(1, "tree_merge: duplicate"); } }
void options_free(struct options *oo) { struct options_entry *o; while (!SPLAY_EMPTY(&oo->tree)) { o = SPLAY_ROOT(&oo->tree); SPLAY_REMOVE(options_tree, &oo->tree, o); xfree(o->name); if (o->type == OPTIONS_STRING) xfree(o->value.string); xfree(o); } }
void mode_key_free_trees(void) { const struct mode_key_table *mtab; struct mode_key_binding *mbind; for (mtab = mode_key_tables; mtab->name != NULL; mtab++) { while (!SPLAY_EMPTY(mtab->tree)) { mbind = SPLAY_ROOT(mtab->tree); SPLAY_REMOVE(mode_key_tree, mtab->tree, mbind); xfree(mbind); } } }
void tree_merge(struct tree *dst, struct tree *src) { struct treeentry *entry; while (!SPLAY_EMPTY(&src->tree)) { entry = SPLAY_ROOT(&src->tree); SPLAY_REMOVE(_tree, &src->tree, entry); if (SPLAY_INSERT(_tree, &dst->tree, entry)) errx(1, "tree_merge: duplicate"); } dst->count += src->count; src->count = 0; }
void dict_merge(struct dict *dst, struct dict *src) { struct dictentry *entry; while (!SPLAY_EMPTY(&src->dict)) { entry = SPLAY_ROOT(&src->dict); SPLAY_REMOVE(_dict, &src->dict, entry); if (SPLAY_INSERT(_dict, &dst->dict, entry)) errx(1, "dict_merge: duplicate"); } dst->count += src->count; src->count = 0; }
void options_free(struct options *oo) { struct options_entry *o; while (!SPLAY_EMPTY(&oo->tree)) { o = SPLAY_ROOT(&oo->tree); SPLAY_REMOVE(options_tree, &oo->tree, o); xfree(o->name); if (o->type == OPTIONS_STRING) xfree(o->str); else if (o->type == OPTIONS_DATA) o->freefn(o->data); xfree(o); } }
void fs_vnode_cleanup(vnode_t * vnode) { struct buf * var, * nxt; KASSERT(vnode != NULL, "vnode can't be null."); /* Release associated buffers. */ if (!SPLAY_EMPTY(&vnode->vn_bpo.sroot)) { for (var = SPLAY_MIN(bufhd_splay, &vnode->vn_bpo.sroot); var != NULL; var = nxt) { nxt = SPLAY_NEXT(bufhd_splay, &vnode->vn_bpo.sroot, var); SPLAY_REMOVE(bufhd_splay, &vnode->vn_bpo.sroot, var); if (!(var->b_flags & B_DONE)) var->b_flags |= B_DELWRI; brelse(var); } } }
int cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) { struct cmd_unbind_key_data *data = self->data; struct key_binding *bd; if (data == NULL) return (0); if (data->flag_all) { while (!SPLAY_EMPTY(&key_bindings)) { bd = SPLAY_ROOT(&key_bindings); SPLAY_REMOVE(key_bindings, &key_bindings, bd); cmd_list_free(bd->cmdlist); xfree(bd); } } else { if (data->tablename != NULL) return (cmd_unbind_key_table(self, ctx)); key_bindings_remove(data->key); } return (0); }