ui/common/types.c

branch
newapi
changeset 243
9f66c31a27ed
parent 241
c51dd0e9ecb7
child 246
b19f3098dd11
--- a/ui/common/types.c	Wed Jan 31 19:15:41 2024 +0100
+++ b/ui/common/types.c	Thu Feb 01 19:45:17 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);
+}

mercurial