diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-29 09:10:07 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-29 09:11:15 -0500 |
commit | bd3ca70e3d67476f4d66e9bc31c67b11aefb3519 (patch) | |
tree | 067b8a56585a9a13edbc2b3ecd6088015e486912 /sway/commands | |
parent | 62b7ab3959468124086a1ba95361b3eed069b4a7 (diff) |
fix nitpicks
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/bind.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 99f54f46..ef9a4b7a 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -16,15 +16,14 @@ int binding_order = 0; void free_sway_binding(struct sway_binding *binding) { - if (binding->keys) { - for (int i = 0; i < binding->keys->length; i++) { - free(binding->keys->items[i]); - } - list_free(binding->keys); + if (!binding) { + return; } - if (binding->command) { - free(binding->command); + + if (binding->keys) { + free_flat_list(binding->keys); } + free(binding->command); free(binding); } @@ -72,7 +71,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { return error; } - struct sway_binding *binding = malloc(sizeof(struct sway_binding)); + struct sway_binding *binding = calloc(1, sizeof(struct sway_binding)); if (!binding) { return cmd_results_new(CMD_FAILURE, "bindsym", "Unable to allocate binding"); @@ -122,7 +121,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { free_flat_list(split); return ret; } - xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); + xkb_keysym_t *key = calloc(1, sizeof(xkb_keysym_t)); if (!key) { free_sway_binding(binding); free_flat_list(split); @@ -165,7 +164,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) { return error; } - struct sway_binding *binding = malloc(sizeof(struct sway_binding)); + struct sway_binding *binding = calloc(1, sizeof(struct sway_binding)); if (!binding) { return cmd_results_new(CMD_FAILURE, "bindsym", "Unable to allocate binding"); @@ -209,7 +208,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) { list_free(split); return error; } - xkb_keycode_t *key = malloc(sizeof(xkb_keycode_t)); + xkb_keycode_t *key = calloc(1, sizeof(xkb_keycode_t)); *key = keycode - 8; list_add(binding->keys, key); } |