diff --git a/include/stringop.h b/include/stringop.h index 4300f9ed..7d17af95 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -4,8 +4,11 @@ char *strip_whitespace(char *str, int *trimmed_start); char *strip_comments(char *str); + +// Must be freed with free_flat_list list_t *split_string(const char *str, const char *delims); void free_flat_list(list_t *list); + char *code_strchr(const char *string, char delimiter); char *code_strstr(const char *haystack, const char *needle); int unescape_string(char *string); diff --git a/sway/commands.c b/sway/commands.c index 7ee8c558..21ff5c7f 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -129,7 +129,7 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) { *key = sym; list_add(binding->keys, key); } - list_free(split); + free_flat_list(split); // TODO: Check if there are other commands with this key binding struct sway_mode *mode = config->current_mode; @@ -268,7 +268,7 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) } } } - list_free(split); + free_flat_list(split); if (!config->floating_mod) { sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]); return false; diff --git a/sway/config.c b/sway/config.c index fcd60de7..53fc860a 100644 --- a/sway/config.c +++ b/sway/config.c @@ -131,6 +131,7 @@ static char *get_config_path() { strcpy(test, paths->items[i]); strcat(test, name); if (exists(test)) { + free_config(temp_config); free_flat_list(paths); return test; } @@ -225,7 +226,7 @@ bool read_config(FILE *file, bool is_active) { success = false; temp_config->failed = true; } - list_free(args); + free_flat_list(args); _continue: if (line && line[strlen(line) - 1] == '{') { diff --git a/sway/workspace.c b/sway/workspace.c index 80b67128..4c8bb62f 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -42,22 +42,22 @@ char *workspace_next_name(void) { strcmp(target, "back_and_forth") == 0 || strcmp(target, "current") == 0) { - list_free(args); + free_flat_list(args); continue; } // Make sure that the workspace doesn't already exist if (workspace_by_name(target)) { - list_free(args); + free_flat_list(args); continue; } - list_free(args); + free_flat_list(args); sway_log(L_DEBUG, "Workspace: Found free name %s", target); return target; } - list_free(args); + free_flat_list(args); } // As a fall back, get the current number of active workspaces // and return that + 1 for the next workspace's name