]> gitweb.hhaalo.de Git - discspan.git/commitdiff
change: collection free in one method
authorBastian Dehn <hhaalo@arcor.de>
Sat, 14 Aug 2021 18:23:38 +0000 (20:23 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 14 Aug 2021 18:23:38 +0000 (20:23 +0200)
libs/spandisc/src/logic.c

index 0ab352d2c0a88f1ebad0f3adb51fc3fc021c4c5b..2bdfb57ffe1354aa076e47f6615c54a08823ab82 100644 (file)
@@ -28,6 +28,15 @@ int cmpfunc(const void *filea, const void *fileb)
                return -2;
 }
 
+void free_collection(collection_t *data)
+{
+       for (int i = 0; i < data->length; i++) {
+               free(data->disc[i].filearray);
+       }
+
+       free(data->disc);
+}
+
 void span(const char *input, const char *output, unsigned long long split)
 {
        medium_t srcdata = { 0, split, 0, NULL };
@@ -42,8 +51,7 @@ void span(const char *input, const char *output, unsigned long long split)
                sprintf(outname, "%s%04d", output, col.disc[i].nr);
                on_status_print(outname, col.disc[i]);
                write_output_file(outname, col.disc[i]);
-               free(col.disc[i].filearray);
        }
 
-       free(col.disc);
+       free_collection(&col);
 }