diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2017-12-29 11:31:08 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2018-01-05 00:07:34 +0100 |
commit | 9a326be7f881f8589049a517b9e3112b562d81ea (patch) | |
tree | 3e872b080cf7b99c3aeb7799835eb633e15d5421 | |
parent | fix typos in comments/messages; add shutting down message (diff) | |
download | sway-9a326be7f881f8589049a517b9e3112b562d81ea.tar.gz sway-9a326be7f881f8589049a517b9e3112b562d81ea.tar.zst sway-9a326be7f881f8589049a517b9e3112b562d81ea.zip |
config: leak sanitizer pass
Add free for everything that's implemented right now.
Will need to add more as the implementations are re-added.
-rw-r--r-- | sway/config.c | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/sway/config.c b/sway/config.c index 53a54a07..37f6e75a 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -31,8 +31,79 @@ | |||
31 | 31 | ||
32 | struct sway_config *config = NULL; | 32 | struct sway_config *config = NULL; |
33 | 33 | ||
34 | static void free_binding(struct sway_binding *bind) { | ||
35 | if (!bind) { | ||
36 | return; | ||
37 | } | ||
38 | free_flat_list(bind->keys); | ||
39 | free(bind->command); | ||
40 | free(bind); | ||
41 | } | ||
42 | |||
43 | static void free_mode(struct sway_mode *mode) { | ||
44 | int i; | ||
45 | |||
46 | if (!mode) { | ||
47 | return; | ||
48 | } | ||
49 | free(mode->name); | ||
50 | if (mode->keysym_bindings) { | ||
51 | for (i = 0; i < mode->keysym_bindings->length; i++) { | ||
52 | free_binding(mode->keysym_bindings->items[i]); | ||
53 | } | ||
54 | list_free(mode->keysym_bindings); | ||
55 | } | ||
56 | if (mode->keycode_bindings) { | ||
57 | for (i = 0; i < mode->keycode_bindings->length; i++) { | ||
58 | free_binding(mode->keycode_bindings->items[i]); | ||
59 | } | ||
60 | list_free(mode->keycode_bindings); | ||
61 | } | ||
62 | free(mode); | ||
63 | } | ||
64 | |||
34 | void free_config(struct sway_config *config) { | 65 | void free_config(struct sway_config *config) { |
35 | // TODO | 66 | int i; |
67 | |||
68 | if (!config) { | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | // TODO: handle all currently unhandled lists as we add implementations | ||
73 | list_free(config->symbols); | ||
74 | if (config->modes) { | ||
75 | for (i = 0; i < config->modes->length; i++) { | ||
76 | free_mode(config->modes->items[i]); | ||
77 | } | ||
78 | list_free(config->modes); | ||
79 | } | ||
80 | list_free(config->bars); | ||
81 | list_free(config->cmd_queue); | ||
82 | list_free(config->workspace_outputs); | ||
83 | list_free(config->pid_workspaces); | ||
84 | list_free(config->output_configs); | ||
85 | if (config->input_configs) { | ||
86 | for (i = 0; i < config->input_configs->length; i++) { | ||
87 | free_input_config(config->input_configs->items[i]); | ||
88 | } | ||
89 | list_free(config->input_configs); | ||
90 | } | ||
91 | list_free(config->seat_configs); | ||
92 | list_free(config->criteria); | ||
93 | list_free(config->no_focus); | ||
94 | list_free(config->active_bar_modifiers); | ||
95 | list_free(config->config_chain); | ||
96 | list_free(config->command_policies); | ||
97 | list_free(config->feature_policies); | ||
98 | list_free(config->ipc_policies); | ||
99 | free(config->current_bar); | ||
100 | free(config->floating_scroll_up_cmd); | ||
101 | free(config->floating_scroll_down_cmd); | ||
102 | free(config->floating_scroll_left_cmd); | ||
103 | free(config->floating_scroll_right_cmd); | ||
104 | free(config->font); | ||
105 | free((char *)config->current_config); | ||
106 | free(config); | ||
36 | } | 107 | } |
37 | 108 | ||
38 | static void config_defaults(struct sway_config *config) { | 109 | static void config_defaults(struct sway_config *config) { |
@@ -186,6 +257,7 @@ static char *get_config_path(void) { | |||
186 | if (file_exists(path)) { | 257 | if (file_exists(path)) { |
187 | return path; | 258 | return path; |
188 | } | 259 | } |
260 | free(path); | ||
189 | } | 261 | } |
190 | } | 262 | } |
191 | 263 | ||
@@ -524,6 +596,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
524 | 596 | ||
525 | case CMD_BLOCK_INPUT: | 597 | case CMD_BLOCK_INPUT: |
526 | sway_log(L_DEBUG, "End of input block"); | 598 | sway_log(L_DEBUG, "End of input block"); |
599 | free_input_config(current_input_config); | ||
527 | current_input_config = NULL; | 600 | current_input_config = NULL; |
528 | block = CMD_BLOCK_END; | 601 | block = CMD_BLOCK_END; |
529 | break; | 602 | break; |