aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-12-09 01:15:23 +0000
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-12-09 01:15:38 +0000
commit98c1e19466c0d83c8e1ca86eda5b273eda7eff3c (patch)
treeb47ccc174669786e3a1df9569046886c23003a45
parentCleanup list code (diff)
downloadsway-98c1e19466c0d83c8e1ca86eda5b273eda7eff3c.tar.gz
sway-98c1e19466c0d83c8e1ca86eda5b273eda7eff3c.tar.zst
sway-98c1e19466c0d83c8e1ca86eda5b273eda7eff3c.zip
list.c: rename free_flat_list to list_free_items_and_destroy
-rw-r--r--common/list.c2
-rw-r--r--common/loop.c4
-rw-r--r--include/list.h2
-rw-r--r--include/stringop.h2
-rw-r--r--sway/commands/bar/modifier.c4
-rw-r--r--sway/commands/bind.c6
-rw-r--r--sway/commands/reload.c4
-rw-r--r--sway/commands/workspace.c2
-rw-r--r--sway/config.c8
-rw-r--r--sway/config/bar.c2
-rw-r--r--sway/tree/container.c2
-rw-r--r--sway/tree/workspace.c2
12 files changed, 20 insertions, 20 deletions
diff --git a/common/list.c b/common/list.c
index 2a803702..9805ceec 100644
--- a/common/list.c
+++ b/common/list.c
@@ -147,7 +147,7 @@ void list_stable_sort(list_t *list, int compare(const void *a, const void *b)) {
147 } 147 }
148} 148}
149 149
150void free_flat_list(list_t *list) { 150void list_free_items_and_destroy(list_t *list) {
151 if (!list) { 151 if (!list) {
152 return; 152 return;
153 } 153 }
diff --git a/common/loop.c b/common/loop.c
index ad2b4a64..295f3a30 100644
--- a/common/loop.c
+++ b/common/loop.c
@@ -45,8 +45,8 @@ struct loop *loop_create(void) {
45} 45}
46 46
47void loop_destroy(struct loop *loop) { 47void loop_destroy(struct loop *loop) {
48 free_flat_list(loop->fd_events); 48 list_free_items_and_destroy(loop->fd_events);
49 free_flat_list(loop->timers); 49 list_free_items_and_destroy(loop->timers);
50 free(loop->fds); 50 free(loop->fds);
51 free(loop); 51 free(loop);
52} 52}
diff --git a/include/list.h b/include/list.h
index 70af49f6..895f6cc0 100644
--- a/include/list.h
+++ b/include/list.h
@@ -31,5 +31,5 @@ void list_move_to_end(list_t *list, void *item);
31 * Do not use this to free lists of primitives or items that require more 31 * Do not use this to free lists of primitives or items that require more
32 * complicated deallocation code. 32 * complicated deallocation code.
33 */ 33 */
34void free_flat_list(list_t *list); 34void list_free_items_and_destroy(list_t *list);
35#endif 35#endif
diff --git a/include/stringop.h b/include/stringop.h
index 215f7916..d1bfa29d 100644
--- a/include/stringop.h
+++ b/include/stringop.h
@@ -17,7 +17,7 @@ char *lenient_strncat(char *dest, const char *src, size_t len);
17// strcmp that also handles null pointers. 17// strcmp that also handles null pointers.
18int lenient_strcmp(char *a, char *b); 18int lenient_strcmp(char *a, char *b);
19 19
20// Simply split a string with delims, free with `free_flat_list` 20// Simply split a string with delims, free with `list_free_items_and_destroy`
21list_t *split_string(const char *str, const char *delims); 21list_t *split_string(const char *str, const char *delims);
22 22
23// Splits an argument string, keeping quotes intact 23// Splits an argument string, keeping quotes intact
diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c
index 1b3e7492..b5a16f45 100644
--- a/sway/commands/bar/modifier.c
+++ b/sway/commands/bar/modifier.c
@@ -23,11 +23,11 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) {
23 } else { 23 } else {
24 error = cmd_results_new(CMD_INVALID, "modifier", 24 error = cmd_results_new(CMD_INVALID, "modifier",
25 "Unknown modifier '%s'", split->items[i]); 25 "Unknown modifier '%s'", split->items[i]);
26 free_flat_list(split); 26 list_free_items_and_destroy(split);
27 return error; 27 return error;
28 } 28 }
29 } 29 }
30 free_flat_list(split); 30 list_free_items_and_destroy(split);
31 config->current_bar->modifier = mod; 31 config->current_bar->modifier = mod;
32 wlr_log(WLR_DEBUG, 32 wlr_log(WLR_DEBUG,
33 "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]); 33 "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]);
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index 886a262c..01a35cf2 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -23,7 +23,7 @@ void free_sway_binding(struct sway_binding *binding) {
23 return; 23 return;
24 } 24 }
25 25
26 free_flat_list(binding->keys); 26 list_free_items_and_destroy(binding->keys);
27 free(binding->input); 27 free(binding->input);
28 free(binding->command); 28 free(binding->command);
29 free(binding); 29 free(binding);
@@ -220,14 +220,14 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv,
220 uint32_t *key = calloc(1, sizeof(uint32_t)); 220 uint32_t *key = calloc(1, sizeof(uint32_t));
221 if (!key) { 221 if (!key) {
222 free_sway_binding(binding); 222 free_sway_binding(binding);
223 free_flat_list(split); 223 list_free_items_and_destroy(split);
224 return cmd_results_new(CMD_FAILURE, bindtype, 224 return cmd_results_new(CMD_FAILURE, bindtype,
225 "Unable to allocate binding key"); 225 "Unable to allocate binding key");
226 } 226 }
227 *key = key_val; 227 *key = key_val;
228 list_add(binding->keys, key); 228 list_add(binding->keys, key);
229 } 229 }
230 free_flat_list(split); 230 list_free_items_and_destroy(split);
231 binding->order = binding_order++; 231 binding->order = binding_order++;
232 232
233 // refine region of interest for mouse binding once we are certain 233 // refine region of interest for mouse binding once we are certain
diff --git a/sway/commands/reload.c b/sway/commands/reload.c
index c236911e..3ccbbf34 100644
--- a/sway/commands/reload.c
+++ b/sway/commands/reload.c
@@ -24,7 +24,7 @@ static void do_reload(void *data) {
24 24
25 if (!load_main_config(config->current_config_path, true, false)) { 25 if (!load_main_config(config->current_config_path, true, false)) {
26 wlr_log(WLR_ERROR, "Error(s) reloading config"); 26 wlr_log(WLR_ERROR, "Error(s) reloading config");
27 free_flat_list(bar_ids); 27 list_free_items_and_destroy(bar_ids);
28 return; 28 return;
29 } 29 }
30 30
@@ -41,7 +41,7 @@ static void do_reload(void *data) {
41 } 41 }
42 } 42 }
43 } 43 }
44 free_flat_list(bar_ids); 44 list_free_items_and_destroy(bar_ids);
45 45
46 config_update_font_height(true); 46 config_update_font_height(true);
47 root_for_each_container(rebuild_textures_iterator, NULL); 47 root_for_each_container(rebuild_textures_iterator, NULL);
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 7d32e65b..211b344d 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -33,7 +33,7 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
33 33
34void free_workspace_config(struct workspace_config *wsc) { 34void free_workspace_config(struct workspace_config *wsc) {
35 free(wsc->workspace); 35 free(wsc->workspace);
36 free_flat_list(wsc->outputs); 36 list_free_items_and_destroy(wsc->outputs);
37 free(wsc); 37 free(wsc);
38} 38}
39 39
diff --git a/sway/config.c b/sway/config.c
index 4621cad9..5b03bc56 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -444,7 +444,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
444 } 444 }
445 } 445 }
446 446
447 free_flat_list(secconfigs); 447 list_free_items_and_destroy(secconfigs);
448 } 448 }
449 */ 449 */
450 450
@@ -652,7 +652,7 @@ bool read_config(FILE *file, struct sway_config *config,
652 652
653 if (read + length > config_size) { 653 if (read + length > config_size) {
654 wlr_log(WLR_ERROR, "Config file changed during reading"); 654 wlr_log(WLR_ERROR, "Config file changed during reading");
655 free_flat_list(stack); 655 list_free_items_and_destroy(stack);
656 free(line); 656 free(line);
657 return false; 657 return false;
658 } 658 }
@@ -681,7 +681,7 @@ bool read_config(FILE *file, struct sway_config *config,
681 } 681 }
682 char *expanded = expand_line(block, line, brace_detected > 0); 682 char *expanded = expand_line(block, line, brace_detected > 0);
683 if (!expanded) { 683 if (!expanded) {
684 free_flat_list(stack); 684 list_free_items_and_destroy(stack);
685 free(line); 685 free(line);
686 return false; 686 return false;
687 } 687 }
@@ -746,7 +746,7 @@ bool read_config(FILE *file, struct sway_config *config,
746 free(line); 746 free(line);
747 free_cmd_results(res); 747 free_cmd_results(res);
748 } 748 }
749 free_flat_list(stack); 749 list_free_items_and_destroy(stack);
750 config->current_config_line_number = 0; 750 config->current_config_line_number = 0;
751 config->current_config_line = NULL; 751 config->current_config_line = NULL;
752 752
diff --git a/sway/config/bar.c b/sway/config/bar.c
index fc773026..45c9e998 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -52,7 +52,7 @@ void free_bar_config(struct bar_config *bar) {
52 free_bar_binding(bar->bindings->items[i]); 52 free_bar_binding(bar->bindings->items[i]);
53 } 53 }
54 list_free(bar->bindings); 54 list_free(bar->bindings);
55 free_flat_list(bar->outputs); 55 list_free_items_and_destroy(bar->outputs);
56 if (bar->pid != 0) { 56 if (bar->pid != 0) {
57 terminate_swaybar(bar->pid); 57 terminate_swaybar(bar->pid);
58 } 58 }
diff --git a/sway/tree/container.c b/sway/tree/container.c
index ac433577..b106e0d9 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -68,7 +68,7 @@ void container_destroy(struct sway_container *con) {
68 list_free(con->current.children); 68 list_free(con->current.children);
69 list_free(con->outputs); 69 list_free(con->outputs);
70 70
71 free_flat_list(con->marks); 71 list_free_items_and_destroy(con->marks);
72 wlr_texture_destroy(con->marks_focused); 72 wlr_texture_destroy(con->marks_focused);
73 wlr_texture_destroy(con->marks_focused_inactive); 73 wlr_texture_destroy(con->marks_focused_inactive);
74 wlr_texture_destroy(con->marks_unfocused); 74 wlr_texture_destroy(con->marks_unfocused);
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 4be63311..ed24b4fd 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -142,7 +142,7 @@ void workspace_destroy(struct sway_workspace *workspace) {
142 142
143 free(workspace->name); 143 free(workspace->name);
144 free(workspace->representation); 144 free(workspace->representation);
145 free_flat_list(workspace->output_priority); 145 list_free_items_and_destroy(workspace->output_priority);
146 list_free(workspace->floating); 146 list_free(workspace->floating);
147 list_free(workspace->tiling); 147 list_free(workspace->tiling);
148 list_free(workspace->current.floating); 148 list_free(workspace->current.floating);