From 98c1e19466c0d83c8e1ca86eda5b273eda7eff3c Mon Sep 17 00:00:00 2001 From: Ian Fan Date: Sun, 9 Dec 2018 01:15:23 +0000 Subject: [PATCH] list.c: rename free_flat_list to list_free_items_and_destroy --- common/list.c | 2 +- common/loop.c | 4 ++-- include/list.h | 2 +- include/stringop.h | 2 +- sway/commands/bar/modifier.c | 4 ++-- sway/commands/bind.c | 6 +++--- sway/commands/reload.c | 4 ++-- sway/commands/workspace.c | 2 +- sway/config.c | 8 ++++---- sway/config/bar.c | 2 +- sway/tree/container.c | 2 +- sway/tree/workspace.c | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/common/list.c b/common/list.c index 2a8037022..9805ceeca 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)) { } } -void free_flat_list(list_t *list) { +void list_free_items_and_destroy(list_t *list) { if (!list) { return; } diff --git a/common/loop.c b/common/loop.c index ad2b4a644..295f3a309 100644 --- a/common/loop.c +++ b/common/loop.c @@ -45,8 +45,8 @@ struct loop *loop_create(void) { } void loop_destroy(struct loop *loop) { - free_flat_list(loop->fd_events); - free_flat_list(loop->timers); + list_free_items_and_destroy(loop->fd_events); + list_free_items_and_destroy(loop->timers); free(loop->fds); free(loop); } diff --git a/include/list.h b/include/list.h index 70af49f66..895f6cc01 100644 --- a/include/list.h +++ b/include/list.h @@ -31,5 +31,5 @@ void list_move_to_end(list_t *list, void *item); * Do not use this to free lists of primitives or items that require more * complicated deallocation code. */ -void free_flat_list(list_t *list); +void list_free_items_and_destroy(list_t *list); #endif diff --git a/include/stringop.h b/include/stringop.h index 215f79163..d1bfa29d0 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -17,7 +17,7 @@ char *lenient_strncat(char *dest, const char *src, size_t len); // strcmp that also handles null pointers. int lenient_strcmp(char *a, char *b); -// Simply split a string with delims, free with `free_flat_list` +// Simply split a string with delims, free with `list_free_items_and_destroy` list_t *split_string(const char *str, const char *delims); // Splits an argument string, keeping quotes intact diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c index 1b3e74924..b5a16f45f 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) { } else { error = cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", split->items[i]); - free_flat_list(split); + list_free_items_and_destroy(split); return error; } } - free_flat_list(split); + list_free_items_and_destroy(split); config->current_bar->modifier = mod; wlr_log(WLR_DEBUG, "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 886a262cc..01a35cf2f 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -23,7 +23,7 @@ void free_sway_binding(struct sway_binding *binding) { return; } - free_flat_list(binding->keys); + list_free_items_and_destroy(binding->keys); free(binding->input); free(binding->command); free(binding); @@ -220,14 +220,14 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, uint32_t *key = calloc(1, sizeof(uint32_t)); if (!key) { free_sway_binding(binding); - free_flat_list(split); + list_free_items_and_destroy(split); return cmd_results_new(CMD_FAILURE, bindtype, "Unable to allocate binding key"); } *key = key_val; list_add(binding->keys, key); } - free_flat_list(split); + list_free_items_and_destroy(split); binding->order = binding_order++; // refine region of interest for mouse binding once we are certain diff --git a/sway/commands/reload.c b/sway/commands/reload.c index c236911e9..3ccbbf34e 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -24,7 +24,7 @@ static void do_reload(void *data) { if (!load_main_config(config->current_config_path, true, false)) { wlr_log(WLR_ERROR, "Error(s) reloading config"); - free_flat_list(bar_ids); + list_free_items_and_destroy(bar_ids); return; } @@ -41,7 +41,7 @@ static void do_reload(void *data) { } } } - free_flat_list(bar_ids); + list_free_items_and_destroy(bar_ids); config_update_font_height(true); root_for_each_container(rebuild_textures_iterator, NULL); diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 7d32e65b3..211b344db 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) { void free_workspace_config(struct workspace_config *wsc) { free(wsc->workspace); - free_flat_list(wsc->outputs); + list_free_items_and_destroy(wsc->outputs); free(wsc); } diff --git a/sway/config.c b/sway/config.c index 4621cad91..5b03bc563 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) { } } - free_flat_list(secconfigs); + list_free_items_and_destroy(secconfigs); } */ @@ -652,7 +652,7 @@ bool read_config(FILE *file, struct sway_config *config, if (read + length > config_size) { wlr_log(WLR_ERROR, "Config file changed during reading"); - free_flat_list(stack); + list_free_items_and_destroy(stack); free(line); return false; } @@ -681,7 +681,7 @@ bool read_config(FILE *file, struct sway_config *config, } char *expanded = expand_line(block, line, brace_detected > 0); if (!expanded) { - free_flat_list(stack); + list_free_items_and_destroy(stack); free(line); return false; } @@ -746,7 +746,7 @@ bool read_config(FILE *file, struct sway_config *config, free(line); free_cmd_results(res); } - free_flat_list(stack); + list_free_items_and_destroy(stack); config->current_config_line_number = 0; config->current_config_line = NULL; diff --git a/sway/config/bar.c b/sway/config/bar.c index fc7730269..45c9e9980 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -52,7 +52,7 @@ void free_bar_config(struct bar_config *bar) { free_bar_binding(bar->bindings->items[i]); } list_free(bar->bindings); - free_flat_list(bar->outputs); + list_free_items_and_destroy(bar->outputs); if (bar->pid != 0) { terminate_swaybar(bar->pid); } diff --git a/sway/tree/container.c b/sway/tree/container.c index ac4335772..b106e0d9a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -68,7 +68,7 @@ void container_destroy(struct sway_container *con) { list_free(con->current.children); list_free(con->outputs); - free_flat_list(con->marks); + list_free_items_and_destroy(con->marks); wlr_texture_destroy(con->marks_focused); wlr_texture_destroy(con->marks_focused_inactive); wlr_texture_destroy(con->marks_unfocused); diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 4be633112..ed24b4fdc 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -142,7 +142,7 @@ void workspace_destroy(struct sway_workspace *workspace) { free(workspace->name); free(workspace->representation); - free_flat_list(workspace->output_priority); + list_free_items_and_destroy(workspace->output_priority); list_free(workspace->floating); list_free(workspace->tiling); list_free(workspace->current.floating);