457 l->obj = NULL; |
457 l->obj = NULL; |
458 } |
458 } |
459 |
459 |
460 |
460 |
461 |
461 |
462 UiStr ui_str(char *cstr) { |
462 UIEXPORT UiStr ui_str(char *cstr) { |
463 return (UiStr) { cstr, NULL }; |
463 return (UiStr) { cstr, NULL }; |
464 } |
464 } |
465 |
465 |
466 UiStr ui_str_free(char *str, void (*freefunc)(void *v)) { |
466 UIEXPORT UiStr ui_str_free(char *str, void (*freefunc)(void *v)) { |
467 return (UiStr) { str, freefunc }; |
467 return (UiStr) { str, freefunc }; |
468 } |
468 } |
469 |
469 |
470 |
470 |
471 UiFileList ui_filelist_copy(UiFileList list) { |
471 UIEXPORT UiFileList ui_filelist_copy(UiFileList list) { |
472 char **newlist = calloc(sizeof(char*), list.nfiles); |
472 char **newlist = calloc(sizeof(char*), list.nfiles); |
473 for (int i = 0; i < list.nfiles; i++) { |
473 for (int i = 0; i < list.nfiles; i++) { |
474 newlist[i] = strdup(list.files[i]); |
474 newlist[i] = strdup(list.files[i]); |
475 } |
475 } |
476 return (UiFileList) { newlist, list.nfiles }; |
476 return (UiFileList) { newlist, list.nfiles }; |
477 } |
477 } |
478 |
478 |
479 void ui_filelist_free(UiFileList list) { |
479 UIEXPORT void ui_filelist_free(UiFileList list) { |
480 for (int i = 0; i < list.nfiles; i++) { |
480 for (int i = 0; i < list.nfiles; i++) { |
481 free(list.files[i]); |
481 free(list.files[i]); |
482 } |
482 } |
483 free(list.files); |
483 free(list.files); |
484 } |
484 } |