diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 17 |
1 files changed, 6 insertions, 11 deletions
@@ -91,16 +91,11 @@ int main(int argc, char** argv) if (is_directory(directory)) { // List files in the ddirectory file_list = list_directory(directory); - if (file_list) { - size_t index = 0; - // For each file - while (1) { + if (file_list != NULL) { + for (size_t index = 0; file_list[index] != NULL; index++) { char* fname = file_list[index]; - if (fname == NULL) { - break; - } if (is_tif_ext(fname) == FALSE) { - free(file_list[index++]); + free(file_list[index]); continue; } // If we have a tiff file @@ -110,7 +105,7 @@ int main(int argc, char** argv) // 4. Free up allocations made in this process char* fpath = full_path(directory, fname); if (fpath == NULL) { - free(file_list[index++]); + free(file_list[index]); continue; } if (!silent) { @@ -119,13 +114,13 @@ int main(int argc, char** argv) uint16_t *file_labels = tif_to_labels(fpath, &width, &height, &starting_label); if (file_labels == NULL) { free(fpath); - free(file_list[index++]); + free(file_list[index]); continue; } masks = combine_masks(masks, file_labels, width, height); free(file_labels); free(fpath); - free(file_list[index++]); + free(file_list[index]); } free(file_list); } |