From c9afabcd193718dd6972dabd1a11810014b39a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Tue, 6 Dec 2022 12:09:40 +0100 Subject: [PATCH] Fix memory leaks --- 02/src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/02/src/main.c b/02/src/main.c index da7c51b..cdb039f 100644 --- a/02/src/main.c +++ b/02/src/main.c @@ -37,6 +37,7 @@ int arg_parser(int argc, char *argv[], char **file_name, int *solution_part) { printf("Error: File does not exist.\n"); return 2; } + fclose(file); // Check if the solution part is a valid number if (atoi(argv[2]) != 1 && atoi(argv[2]) != 2) { @@ -141,6 +142,7 @@ int score_file(char **file_name) { my_score += round_score(*opponent, *me); } + fclose(file); return my_score; } @@ -240,6 +242,7 @@ int score_file_part2(char **file_name, int *score) { *score += score_round_part_2(&opponent, &round_res); } + fclose(file); // return score; return 0;