Changeset b13daa0 for keymap.c


Ignore:
Timestamp:
Mar 24, 2011, 4:09:22 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
45e2c95
Parents:
c809f5e
git-author:
David Benjamin <davidben@mit.edu> (03/10/11 15:14:32)
git-committer:
David Benjamin <davidben@mit.edu> (03/24/11 16:09:22)
Message:
Make owl_keybinding new/delete instead of init/cleanup

Valgrind is deeply disappointed in this code...

Hide owl_keybinding_make_keys again, so we don't construct half-baked
owl_keybinding instances. Instead allow for creating a dummy keybinding.
Also, initialize all fields of owl_keybinding, or freeing it afterwards
explodes. Also fix a memory leak in unbindkey.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • keymap.c

    rf25df21 rb13daa0  
    3838  int i;
    3939
    40   if ((kb = g_new(owl_keybinding, 1)) == NULL) return(-1);
    41   if (0 != owl_keybinding_init(kb, keyseq, command, function_fn, desc)) {
    42     g_free(kb);
    43     return(-1);
    44   }
     40  kb = owl_keybinding_new(keyseq, command, function_fn, desc);
     41  if (kb == NULL)
     42    return -1;
    4543  /* see if another matching binding, and if so remove it.
    4644   * otherwise just add this one.
     
    6361  int i;
    6462
    65   if ((kb = g_new(owl_keybinding, 1)) == NULL) return(-1);
    66   if (0 != owl_keybinding_make_keys(kb, keyseq)) {
    67     g_free(kb);
    68     return(-1);
    69   }
     63  kb = owl_keybinding_new(keyseq, NULL, NULL, NULL);
     64  if (kb == NULL)
     65    return -1;
    7066
    7167  for (i = owl_list_get_size(&km->bindings)-1; i >= 0; i--) {
     
    7470      owl_list_remove_element(&km->bindings, i);
    7571      owl_keybinding_delete(curkb);
     72      owl_keybinding_delete(kb);
    7673      return(0);
    7774    }
    7875  }
     76  owl_keybinding_delete(kb);
    7977  return(-2);
    8078}
Note: See TracChangeset for help on using the changeset viewer.