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/bind.c | |
parent | overwrite old bindings (diff) | |
download | sway-bd3ca70e3d67476f4d66e9bc31c67b11aefb3519.tar.gz sway-bd3ca70e3d67476f4d66e9bc31c67b11aefb3519.tar.zst sway-bd3ca70e3d67476f4d66e9bc31c67b11aefb3519.zip |
fix nitpicks
Diffstat (limited to 'sway/commands/bind.c')
-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 @@ | |||
16 | int binding_order = 0; | 16 | int binding_order = 0; |
17 | 17 | ||
18 | void free_sway_binding(struct sway_binding *binding) { | 18 | void free_sway_binding(struct sway_binding *binding) { |
19 | if (binding->keys) { | 19 | if (!binding) { |
20 | for (int i = 0; i < binding->keys->length; i++) { | 20 | return; |
21 | free(binding->keys->items[i]); | ||
22 | } | ||
23 | list_free(binding->keys); | ||
24 | } | 21 | } |
25 | if (binding->command) { | 22 | |
26 | free(binding->command); | 23 | if (binding->keys) { |
24 | free_flat_list(binding->keys); | ||
27 | } | 25 | } |
26 | free(binding->command); | ||
28 | free(binding); | 27 | free(binding); |
29 | } | 28 | } |
30 | 29 | ||
@@ -72,7 +71,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { | |||
72 | return error; | 71 | return error; |
73 | } | 72 | } |
74 | 73 | ||
75 | struct sway_binding *binding = malloc(sizeof(struct sway_binding)); | 74 | struct sway_binding *binding = calloc(1, sizeof(struct sway_binding)); |
76 | if (!binding) { | 75 | if (!binding) { |
77 | return cmd_results_new(CMD_FAILURE, "bindsym", | 76 | return cmd_results_new(CMD_FAILURE, "bindsym", |
78 | "Unable to allocate binding"); | 77 | "Unable to allocate binding"); |
@@ -122,7 +121,7 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { | |||
122 | free_flat_list(split); | 121 | free_flat_list(split); |
123 | return ret; | 122 | return ret; |
124 | } | 123 | } |
125 | xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); | 124 | xkb_keysym_t *key = calloc(1, sizeof(xkb_keysym_t)); |
126 | if (!key) { | 125 | if (!key) { |
127 | free_sway_binding(binding); | 126 | free_sway_binding(binding); |
128 | free_flat_list(split); | 127 | free_flat_list(split); |
@@ -165,7 +164,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) { | |||
165 | return error; | 164 | return error; |
166 | } | 165 | } |
167 | 166 | ||
168 | struct sway_binding *binding = malloc(sizeof(struct sway_binding)); | 167 | struct sway_binding *binding = calloc(1, sizeof(struct sway_binding)); |
169 | if (!binding) { | 168 | if (!binding) { |
170 | return cmd_results_new(CMD_FAILURE, "bindsym", | 169 | return cmd_results_new(CMD_FAILURE, "bindsym", |
171 | "Unable to allocate binding"); | 170 | "Unable to allocate binding"); |
@@ -209,7 +208,7 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) { | |||
209 | list_free(split); | 208 | list_free(split); |
210 | return error; | 209 | return error; |
211 | } | 210 | } |
212 | xkb_keycode_t *key = malloc(sizeof(xkb_keycode_t)); | 211 | xkb_keycode_t *key = calloc(1, sizeof(xkb_keycode_t)); |
213 | *key = keycode - 8; | 212 | *key = keycode - 8; |
214 | list_add(binding->keys, key); | 213 | list_add(binding->keys, key); |
215 | } | 214 | } |