From be78df9fe555b8556f58e490a642c57bca6a493d Mon Sep 17 00:00:00 2001 From: jazzy1902 Date: Mon, 4 Nov 2024 02:51:00 +0530 Subject: [PATCH] free_mem in sharpen --- lab4/src/sharpener/image_sharpener.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lab4/src/sharpener/image_sharpener.cpp b/lab4/src/sharpener/image_sharpener.cpp index 7309b88..fee640a 100644 --- a/lab4/src/sharpener/image_sharpener.cpp +++ b/lab4/src/sharpener/image_sharpener.cpp @@ -171,15 +171,20 @@ int main(int argc, char **argv) struct image_t *details_image; struct image_t *sharpened_image; - for (int i = 0; i < 500; i++) { + int reps = 1000; + + for (int i = 0; i < reps; i++) { smoothened_image = S1_smoothen(input_image); details_image = S2_find_details(input_image, smoothened_image); sharpened_image = S3_sharpen(input_image, details_image); // Free memory to avoid memory leaks - // free_image(smoothened_image); - // free_image(details_image); - // free_image(sharpened_image); + if(i == reps-1) { + continue; + } + free_image(smoothened_image); + free_image(details_image); + free_image(sharpened_image); } write_ppm_file(argv[2], sharpened_image);