--- a/ui/common/types.c Wed Jan 31 12:55:11 2024 +0100 +++ b/ui/common/types.c Tue Feb 06 14:17:22 2024 +0100 @@ -466,3 +466,19 @@ UiStr ui_str_free(char *str, void (*freefunc)(void *v)) { return (UiStr) { str, freefunc }; } + + +UiFileList ui_filelist_copy(UiFileList list) { + char **newlist = calloc(sizeof(char*), list.nfiles); + for (int i = 0; i < list.nfiles; i++) { + newlist[i] = strdup(list.files[i]); + } + return (UiFileList) { newlist, list.nfiles }; +} + +void ui_filelist_free(UiFileList list) { + for (int i = 0; i < list.nfiles; i++) { + free(list.files[i]); + } + free(list.files); +}