summaryrefslogtreecommitdiff
path: root/src/keys.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-05-03 14:36:20 -0400
committercorvid <corvid@lavabit.com>2009-05-03 14:36:20 -0400
commit5e6c65f288006a0c988a91e8aba0d4a23c080299 (patch)
treecc14a619b8ce858eef7700186a011327e8efb9a5 /src/keys.cc
parent90b7c1ea18d41ffb3f57ec4a7048faa3b9737249 (diff)
Fixed a memory leak in keybindings.
Diffstat (limited to 'src/keys.cc')
-rw-r--r--src/keys.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/keys.cc b/src/keys.cc
index 93bec708..147c9935 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -129,8 +129,10 @@ void Keys::free()
{
KeyBinding_t *node;
- while ((node = (KeyBinding_t*)dList_nth_data(bindings, 0)))
+ while ((node = (KeyBinding_t*)dList_nth_data(bindings, 0))) {
dFree((char*)node->name);
+ dFree(node);
+ }
dList_free(bindings);
}
@@ -155,8 +157,7 @@ int Keys::getKeyCmd()
keyNode.key = fltk::event_key();
keyNode.modifier = fltk::event_state();
- void *data = dList_find_sorted(bindings, &keyNode,
- (dCompareFunc)nodeByKeyCmp);
+ void *data = dList_find_sorted(bindings, &keyNode, nodeByKeyCmp);
if (data)
ret = ((KeyBinding_t*)data)->cmd;
return ret;
@@ -167,14 +168,16 @@ int Keys::getKeyCmd()
*/
void Keys::delKeyCmd(int key, int mod)
{
- KeyBinding_t keyNode;
+ KeyBinding_t keyNode, *node;
keyNode.key = key;
keyNode.modifier = mod;
- void *data = dList_find_sorted(bindings, &keyNode,
- (dCompareFunc)nodeByKeyCmp);
- if (data)
- dList_remove(bindings, data);
+ node = (KeyBinding_t*) dList_find_sorted(bindings, &keyNode, nodeByKeyCmp);
+ if (node) {
+ dList_remove(bindings, node);
+ dFree((char*)node->name);
+ dFree(node);
+ }
}
/*