diff options
author | pommicket <pommicket@gmail.com> | 2022-08-19 16:59:33 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-08-19 16:59:33 -0400 |
commit | a97059abea8a15fc26c3ddad66951a04e68fda23 (patch) | |
tree | 34a351aa2015fb943ef2622f979640d8884fd8b5 | |
parent | a2097dfcd797fb2e04f1a8a1547119d7c003c1c6 (diff) |
remove "hacky" file selector code which might fix crash (?)
-rw-r--r-- | ui.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -162,7 +162,7 @@ static void selector_render(Ted *ted, Selector *s) { // clear the entries in the file selector static void file_selector_clear_entries(FileSelector *fs) { for (u32 i = 0; i < fs->n_entries; ++i) { - free(fs->entries[i].name - offsetof(FsDirectoryEntry, name)); // yes this is kinda hacky; oh well + free(fs->entries[i].name); free(fs->entries[i].path); } free(fs->entries); @@ -455,7 +455,7 @@ static char *file_selector_update(Ted *ted, FileSelector *fs) { fs->entries = entries; for (u32 i = 0; i < nfiles; ++i) { char *name = files[i]->name; - entries[i].name = name; + entries[i].name = str_dup(name); entries[i].type = files[i]->type; // add cwd to start of file name size_t path_size = strlen(name) + strlen(cwd) + 3; @@ -466,6 +466,8 @@ static char *file_selector_update(Ted *ted, FileSelector *fs) { } else { entries[i].path = NULL; // what can we do? } + free(files[i]); + files[i] = NULL; } } qsort_with_context(entries, nfiles, sizeof *entries, qsort_file_entry_cmp, search_term); |