mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Fix two problems with conf_unbind():
1) it used TAILQ_FOREACH() when it's removing entrys from the list, this is bad. 2) We didn't free key, so there was a small memleak too. also rework conf_bindname's logic slightly to be more simple. ok okan@
This commit is contained in:
parent
27b023ebcb
commit
b700be764a
16
conf.c
16
conf.c
|
@ -348,11 +348,8 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||||
current_binding->flags = name_to_kbfunc[iter].flags;
|
current_binding->flags = name_to_kbfunc[iter].flags;
|
||||||
current_binding->argument = name_to_kbfunc[iter].argument;
|
current_binding->argument = name_to_kbfunc[iter].argument;
|
||||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name_to_kbfunc[iter].tag != NULL)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
current_binding->callback = kbfunc_cmdexec;
|
current_binding->callback = kbfunc_cmdexec;
|
||||||
current_binding->argument = xstrdup(binding);
|
current_binding->argument = xstrdup(binding);
|
||||||
|
@ -363,15 +360,20 @@ conf_bindname(struct conf *c, char *name, char *binding)
|
||||||
|
|
||||||
void conf_unbind(struct conf *c, struct keybinding *unbind)
|
void conf_unbind(struct conf *c, struct keybinding *unbind)
|
||||||
{
|
{
|
||||||
struct keybinding *key = NULL;
|
struct keybinding *key = NULL, *keynxt;
|
||||||
|
|
||||||
|
for (key = TAILQ_FIRST(&c->keybindingq);
|
||||||
|
key != TAILQ_END(&c->keybindingq); key = keynxt) {
|
||||||
|
keynxt = TAILQ_NEXT(key, entry);
|
||||||
|
|
||||||
TAILQ_FOREACH(key, &c->keybindingq, entry) {
|
|
||||||
if (key->modmask != unbind->modmask)
|
if (key->modmask != unbind->modmask)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((key->keycode != 0 && key->keysym == NoSymbol &&
|
if ((key->keycode != 0 && key->keysym == NoSymbol &&
|
||||||
key->keycode == unbind->keycode) ||
|
key->keycode == unbind->keycode) ||
|
||||||
key->keysym == unbind->keysym)
|
key->keysym == unbind->keysym) {
|
||||||
TAILQ_REMOVE(&c->keybindingq, key, entry);
|
TAILQ_REMOVE(&c->keybindingq, key, entry);
|
||||||
|
xfree(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user