From 2a1e05886aefc9342bf37d4ebf70297ed4aee89c Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 4 Feb 2023 18:12:32 +0100 Subject: [PATCH] implemented why2_clean_memory in why2_init_logger --- src/logger/lib/logger.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index 346ca77..bca618c 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -27,6 +27,7 @@ along with this program. If not, see . #include #include +#include #include #include @@ -34,6 +35,8 @@ along with this program. If not, see . why2_log_file why2_init_logger(char *directoryPath) { + why2_set_memory_identifier("logger_logfile_init"); + //VARIABLES struct stat st; struct dirent *entry; @@ -82,7 +85,14 @@ why2_log_file why2_init_logger(char *directoryPath) latestFilePath = why2_strdup(filePath); if (access(latestBuffer, R_OK) == 0) { unlink(latestBuffer); } //REMOVE SYMLINK IF IT ALREADY EXISTS - (void) (symlink(latestFilePath + (strlen(WHY2_WRITE_DIR) + 1), latestBuffer) + 1); //TODO: Try to create some function for processing exit value //CREATE + + if (symlink(latestFilePath + (strlen(WHY2_WRITE_DIR) + 1), latestBuffer) != 0) //CREATE SYMLINK + { + fprintf(stderr, "Creating symlink failed!\n"); + + why2_clean_memory("logger_logfile_init"); + return why2_empty_log_file(); + } deallocation: @@ -92,6 +102,8 @@ why2_log_file why2_init_logger(char *directoryPath) why2_free(latestFilePath); closedir(dir); + why2_reset_memory_identifier(); + return (why2_log_file) { file,