From ec7436a01deb8e28743de47ad98950c914d6da2a Mon Sep 17 00:00:00 2001 From: Christian C Date: Tue, 1 Apr 2025 20:46:17 -0700 Subject: Global Allocator Checking --- src/prog.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/prog.c b/src/prog.c index 528450e..e08bb72 100644 --- a/src/prog.c +++ b/src/prog.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -96,7 +97,7 @@ int main(int arg_count, char **arg_value) { for (size_t index = 0; file_list[index] != NULL; index++) { char *fname = file_list[index]; if (is_tif_ext(fname) == FALSE) { - free(file_list[index]); + g_free(file_list[index]); continue; } // If we have a tiff file @@ -106,7 +107,7 @@ int main(int arg_count, char **arg_value) { // 4. Free up allocations made in this process char *fpath = full_path(process_directory, fname); if (fpath == NULL) { - free(file_list[index]); + g_free(file_list[index]); continue; } if (!suppress_outputs_b) { @@ -117,8 +118,8 @@ int main(int arg_count, char **arg_value) { //----------------------------------------------- Mask *file_im = tif_to_labels(fpath, &starting_label); if (file_im == NULL) { - free(fpath); - free(file_list[index]); + g_free(fpath); + g_free(file_list[index]); continue; } //----------------------------------------------- @@ -126,10 +127,10 @@ int main(int arg_count, char **arg_value) { //----------------------------------------------- masks_im = combine_masks(masks_im, file_im); free_image_mask(file_im); - free(fpath); - free(file_list[index]); + g_free(fpath); + g_free(file_list[index]); } - free(file_list); + g_free(file_list); } } } @@ -205,7 +206,7 @@ int main(int arg_count, char **arg_value) { Bitmap *bitmap = image_mask_data_to_bitmap(masks_im); if (bitmap != NULL) { save_png(bitmap, png_output_file_fullpath); - free(bitmap); + g_free(bitmap); } write_array(bin_output_file_fullpath, masks_im->image[0], width * height * sizeof(MaskData_t)); @@ -215,5 +216,6 @@ int main(int arg_count, char **arg_value) { if (!suppress_outputs_b) { printf("Finished in %f ms\n", 1000 * diff_time(&ts_g_end, &ts_g_start)); } + printf("Outstanding allocations: %zu\n", g_outstanding_allocations()); return 0; } -- cgit v1.2.1