aboutsummaryrefslogtreecommitdiffstats
path: root/conf.c
diff options
context:
space:
mode:
authoroga2008-05-18 19:47:19 +0000
committeroga2008-05-18 19:47:19 +0000
commitb3be6dd46fcbdd8eecad697f2ead6f2ab25a933b (patch)
tree45a9ff3d9fa86587f3a4e1caa7b9dd8adfcca531 /conf.c
parent71e6f7437aa9210cf26fe38b93552ca3bf86cee3 (diff)
downloadcwm-b3be6dd46fcbdd8eecad697f2ead6f2ab25a933b.tar.gz
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@
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/conf.c b/conf.c
index c7ce9c3..b527262 100644
--- a/conf.c
+++ b/conf.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: conf.c,v 1.30 2008/05/18 19:43:50 oga Exp $
+ * $Id: conf.c,v 1.31 2008/05/18 19:47:19 oga Exp $
*/
#include "headers.h"
@@ -348,11 +348,8 @@ conf_bindname(struct conf *c, char *name, char *binding)
current_binding->flags = name_to_kbfunc[iter].flags;
current_binding->argument = name_to_kbfunc[iter].argument;
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
- break;
- }
-
- if (name_to_kbfunc[iter].tag != NULL)
return;
+ }
current_binding->callback = kbfunc_cmdexec;
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)
{
- 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)
continue;
if ((key->keycode != 0 && key->keysym == NoSymbol &&
key->keycode == unbind->keycode) ||
- key->keysym == unbind->keysym)
+ key->keysym == unbind->keysym) {
TAILQ_REMOVE(&c->keybindingq, key, entry);
+ xfree(key);
+ }
}
}