From d16f48b7608df8e01e8a7b57879d68048457e9a8 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 25 Jan 2023 14:13:52 +0100 Subject: [PATCH] replaced deallocateDoublePointer with deallocateDecryptedOutput --- include/logger/utils.h | 2 +- src/logger/lib/utils.c | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/logger/utils.h b/include/logger/utils.h index 3b5b230..cdf5b28 100644 --- a/include/logger/utils.h +++ b/include/logger/utils.h @@ -22,7 +22,7 @@ along with this program. If not, see . #include void deallocateLogger(logFile logger); //USE THIS IF YOU WANT TO DEALLOCATE FILE POINTER RETURNED BY logger'S initLogger -void deallocateDoublePointer(char **string); //DEALLOCATION OF POINTER-TO-POINTER, WHY TF ARE YOU READING THIS +void deallocateDecryptedOutput(decryptedOutput output); //DEALLOCATION OF POINTER-TO-POINTER, WHY TF ARE YOU READING THIS decryptedOutput decryptLogger(logFile logger); //PASS logger AND FLAGS, AND PROGRAM WILL DECRYPT YOUR LOG... WHAT DID YOU EXPECT? #endif \ No newline at end of file diff --git a/src/logger/lib/utils.c b/src/logger/lib/utils.c index dbbc6d4..725bd9b 100644 --- a/src/logger/lib/utils.c +++ b/src/logger/lib/utils.c @@ -35,21 +35,15 @@ void deallocateLogger(logFile logger) free(logger.fileName); } -void deallocateDoublePointer(char **string) +void deallocateDecryptedOutput(decryptedOutput output) { - int buffer = 0; - - for (; 1; buffer++) //GET string SIZE (FIRST DIM) + for (int i = 0; i < output.length; i++) { - if (!string[buffer]) break; + free(output.decryptedText[i]); } - for (int i = 0; i < buffer; i++) //LOAD ELEMENTS - { - free(string[i]); //DEALLOCATE ELEMENTS - } - - free(string); //no + output.length = 0; + free(output.decryptedText); } decryptedOutput decryptLogger(logFile logger) //TODO: Fix valgrind issues