split_string memory leaks cleanedup

This commit is contained in:
taiyu 2015-08-23 19:09:18 -07:00
parent 9a7f48f872
commit c8415d7fef
4 changed files with 11 additions and 7 deletions

View file

@ -4,8 +4,11 @@
char *strip_whitespace(char *str, int *trimmed_start); char *strip_whitespace(char *str, int *trimmed_start);
char *strip_comments(char *str); char *strip_comments(char *str);
// Must be freed with free_flat_list
list_t *split_string(const char *str, const char *delims); list_t *split_string(const char *str, const char *delims);
void free_flat_list(list_t *list); void free_flat_list(list_t *list);
char *code_strchr(const char *string, char delimiter); char *code_strchr(const char *string, char delimiter);
char *code_strstr(const char *haystack, const char *needle); char *code_strstr(const char *haystack, const char *needle);
int unescape_string(char *string); int unescape_string(char *string);

View file

@ -129,7 +129,7 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) {
*key = sym; *key = sym;
list_add(binding->keys, key); list_add(binding->keys, key);
} }
list_free(split); free_flat_list(split);
// TODO: Check if there are other commands with this key binding // TODO: Check if there are other commands with this key binding
struct sway_mode *mode = config->current_mode; 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) { if (!config->floating_mod) {
sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]); sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]);
return false; return false;

View file

@ -131,6 +131,7 @@ static char *get_config_path() {
strcpy(test, paths->items[i]); strcpy(test, paths->items[i]);
strcat(test, name); strcat(test, name);
if (exists(test)) { if (exists(test)) {
free_config(temp_config);
free_flat_list(paths); free_flat_list(paths);
return test; return test;
} }
@ -225,7 +226,7 @@ bool read_config(FILE *file, bool is_active) {
success = false; success = false;
temp_config->failed = true; temp_config->failed = true;
} }
list_free(args); free_flat_list(args);
_continue: _continue:
if (line && line[strlen(line) - 1] == '{') { if (line && line[strlen(line) - 1] == '{') {

View file

@ -42,22 +42,22 @@ char *workspace_next_name(void) {
strcmp(target, "back_and_forth") == 0 || strcmp(target, "back_and_forth") == 0 ||
strcmp(target, "current") == 0) strcmp(target, "current") == 0)
{ {
list_free(args); free_flat_list(args);
continue; continue;
} }
// Make sure that the workspace doesn't already exist // Make sure that the workspace doesn't already exist
if (workspace_by_name(target)) { if (workspace_by_name(target)) {
list_free(args); free_flat_list(args);
continue; continue;
} }
list_free(args); free_flat_list(args);
sway_log(L_DEBUG, "Workspace: Found free name %s", target); sway_log(L_DEBUG, "Workspace: Found free name %s", target);
return target; return target;
} }
list_free(args); free_flat_list(args);
} }
// As a fall back, get the current number of active workspaces // As a fall back, get the current number of active workspaces
// and return that + 1 for the next workspace's name // and return that + 1 for the next workspace's name