=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/key-bindings.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/tmux/key-bindings.c 2009/06/01 22:58:49 1.1 --- src/usr.bin/tmux/key-bindings.c 2009/07/12 17:33:18 1.2 *************** *** 1,4 **** ! /* $OpenBSD: key-bindings.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: key-bindings.c,v 1.2 2009/07/12 17:33:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 27,32 **** --- 27,33 ---- SPLAY_GENERATE(key_bindings, key_binding, entry, key_bindings_cmp); struct key_bindings key_bindings; + struct key_bindings dead_key_bindings; int key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2) *************** *** 48,59 **** { struct key_binding *bd; ! if ((bd = key_bindings_lookup(key)) == NULL) { ! bd = xmalloc(sizeof *bd); ! bd->key = key; ! SPLAY_INSERT(key_bindings, &key_bindings, bd); ! } else ! cmd_list_free(bd->cmdlist); bd->can_repeat = can_repeat; bd->cmdlist = cmdlist; } --- 49,60 ---- { struct key_binding *bd; ! key_bindings_remove(key); ! ! bd = xmalloc(sizeof *bd); ! bd->key = key; ! SPLAY_INSERT(key_bindings, &key_bindings, bd); ! bd->can_repeat = can_repeat; bd->cmdlist = cmdlist; } *************** *** 66,74 **** if ((bd = key_bindings_lookup(key)) == NULL) return; SPLAY_REMOVE(key_bindings, &key_bindings, bd); ! cmd_list_free(bd->cmdlist); ! xfree(bd); } void --- 67,86 ---- if ((bd = key_bindings_lookup(key)) == NULL) return; SPLAY_REMOVE(key_bindings, &key_bindings, bd); + SPLAY_INSERT(key_bindings, &dead_key_bindings, bd); + } ! 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 *************** *** 162,167 **** --- 174,180 ---- { struct key_binding *bd; + key_bindings_clean(); while (!SPLAY_EMPTY(&key_bindings)) { bd = SPLAY_ROOT(&key_bindings); SPLAY_REMOVE(key_bindings, &key_bindings, bd);