From 6e7ea8b6f535d8b3e9af3462ae874eafb7e64570 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 5 Feb 2023 18:25:42 +0100 Subject: [PATCH] renamed why2_free to why2_deallocate --- include/memory.h | 2 +- src/core/lib/decrypter.c | 8 ++++---- src/core/lib/encrypter.c | 4 ++-- src/core/lib/test/main.c | 8 ++++---- src/core/lib/utils/memory.c | 8 ++++---- src/core/lib/utils/misc.c | 8 ++++---- src/logger/lib/logger.c | 12 ++++++------ src/logger/lib/test/main.c | 2 +- src/logger/lib/utils.c | 8 ++++---- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/memory.h b/include/memory.h index 9ab8cb3..54c6c6e 100644 --- a/include/memory.h +++ b/include/memory.h @@ -12,7 +12,7 @@ void *why2_fdopen(int file, char *modes); int why2_open(char *name, int flags, ...); void *why2_opendir(char *name); -void why2_free(void *pointer); +void why2_deallocate(void *pointer); void why2_clean_memory(char *identifier); //identifier SPECIFIES WHICH NODES TO DEALLOCATE | THIS IS BASICALLY GARBAGE COLLECTOR | PASS why2_get_default_memory_identifier() FOR DEALLOCATING EVERYTHING diff --git a/src/core/lib/decrypter.c b/src/core/lib/decrypter.c index 8fc62f5..54ac32a 100644 --- a/src/core/lib/decrypter.c +++ b/src/core/lib/decrypter.c @@ -146,10 +146,10 @@ why2_output_flags why2_decrypt_text(char *text, char *keyNew) }; //DEALLOCATION - why2_free(textKeyChain); - why2_free(encryptedTextKeyChain); - why2_free(textBuffer); - why2_free(used_text - usedTextDeallocationBuffer); + why2_deallocate(textKeyChain); + why2_deallocate(encryptedTextKeyChain); + why2_deallocate(textBuffer); + why2_deallocate(used_text - usedTextDeallocationBuffer); return output; } diff --git a/src/core/lib/encrypter.c b/src/core/lib/encrypter.c index b47f8f7..86528a6 100644 --- a/src/core/lib/encrypter.c +++ b/src/core/lib/encrypter.c @@ -130,8 +130,8 @@ why2_output_flags why2_encrypt_text(char *text, char *keyNew) }; //DEALLOCATION - why2_free(textKeyChain); - why2_free(textBuffer); + why2_deallocate(textKeyChain); + why2_deallocate(textBuffer); why2_reset_memory_identifier(); diff --git a/src/core/lib/test/main.c b/src/core/lib/test/main.c index 0e93b83..54f102d 100644 --- a/src/core/lib/test/main.c +++ b/src/core/lib/test/main.c @@ -111,10 +111,10 @@ int main(void) ); //DEALLOCATION - why2_free(textBuffer); - why2_free(keyBuffer); - why2_free(statusBuffer); - why2_free(outputBuffer); + why2_deallocate(textBuffer); + why2_deallocate(keyBuffer); + why2_deallocate(statusBuffer); + why2_deallocate(outputBuffer); why2_deallocate_output(encrypted); return exit_code; diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index a734653..9859220 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -124,7 +124,7 @@ void *why2_calloc(unsigned long element, unsigned long size) void *why2_realloc(void *pointer, unsigned long size) { - if (pointer != NULL) why2_free(pointer); + if (pointer != NULL) why2_deallocate(pointer); void *allocated = malloc(size); @@ -142,7 +142,7 @@ char *why2_strdup(char *string) return allocated; } -void why2_free(void *pointer) +void why2_deallocate(void *pointer) { //VARIABLES node_t *node = get_node(pointer); @@ -178,12 +178,12 @@ void why2_clean_memory(char *identifier) while (buffer -> next != NULL) //GO TROUGH LIST { - if (buffer -> identifier == identifier || force_deallocating) why2_free(buffer -> pointer); + if (buffer -> identifier == identifier || force_deallocating) why2_deallocate(buffer -> pointer); buffer = buffer -> next; } - if (buffer -> identifier == identifier || force_deallocating) why2_free(buffer -> pointer); //LAST NODE + if (buffer -> identifier == identifier || force_deallocating) why2_deallocate(buffer -> pointer); //LAST NODE why2_reset_memory_identifier(); //THIS WILL CAUSE SEGFAULT IF YOU DIDN'T USE why2_set_memory_identifier } \ No newline at end of file diff --git a/src/core/lib/utils/misc.c b/src/core/lib/utils/misc.c index 3ddaa59..b5608b5 100644 --- a/src/core/lib/utils/misc.c +++ b/src/core/lib/utils/misc.c @@ -227,7 +227,7 @@ enum WHY2_EXIT_CODES why2_check_version(void) //REMOVE versions.json - OTHERWISE WILL CAUSE SEGFAULT IN NEXT RUN remove(WHY2_VERSIONS_NAME); - why2_free(installCommand); + why2_deallocate(installCommand); //CHECK FOR ERRORS if (installCode != 0) @@ -281,7 +281,7 @@ enum WHY2_EXIT_CODES why2_check_version(void) //DEALLOCATION json_object_put(parsedJson); //THIS FREES EVERY json_object - AT LEAST JSON-C'S DOCUMENTATION SAYS THAT - why2_free(buffer); + why2_deallocate(buffer); why2_reset_memory_identifier(); @@ -326,8 +326,8 @@ void why2_generate_text_key_chain(char *key, int *textKeyChain, int textKeyChain void why2_deallocate_output(why2_output_flags flags) { - why2_free(flags.output_text); - why2_free(flags.used_key); + why2_deallocate(flags.output_text); + why2_deallocate(flags.used_key); flags.elapsed_time = 0; flags.exit_code = WHY2_SUCCESS; diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index 3034995..a3b6ac2 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -97,9 +97,9 @@ why2_log_file why2_init_logger(char *directoryPath) deallocation: //DEALLOCATION - why2_free(dateBuffer); - why2_free(latestBuffer); - why2_free(latestFilePath); + why2_deallocate(dateBuffer); + why2_deallocate(latestBuffer); + why2_deallocate(latestFilePath); closedir(dir); why2_reset_memory_identifier(); @@ -144,7 +144,7 @@ void why2_write_log(int loggerFile, char *logMessage) //DEALLOCATION why2_deallocate_output(encrypted); - why2_free(logMessageUsed); //I COULD DO THIS SMART SOMEHOW, BUT I AM TOO LAZY FOR THAT SHIT + why2_deallocate(logMessageUsed); //I COULD DO THIS SMART SOMEHOW, BUT I AM TOO LAZY FOR THAT SHIT } else //FUCK ENCRYPTION, LET'S DO IT; WHY WOULD WE EVEN USE WHY2-CORE? HUH? { message = logMessageUsed; @@ -160,6 +160,6 @@ void why2_write_log(int loggerFile, char *logMessage) } //DEALLOCATION - why2_free(buffer); - why2_free(message); + why2_deallocate(buffer); + why2_deallocate(message); } \ No newline at end of file diff --git a/src/logger/lib/test/main.c b/src/logger/lib/test/main.c index 1cc898d..a3206c8 100644 --- a/src/logger/lib/test/main.c +++ b/src/logger/lib/test/main.c @@ -74,7 +74,7 @@ int main(void) } //DEALLOCATION - why2_free(used_key); + why2_deallocate(used_key); why2_deallocate_logger(logger); why2_deallocate_decrypted_output(decrypted); diff --git a/src/logger/lib/utils.c b/src/logger/lib/utils.c index 600ffab..7e06e74 100644 --- a/src/logger/lib/utils.c +++ b/src/logger/lib/utils.c @@ -32,7 +32,7 @@ along with this program. If not, see . void why2_deallocate_logger(why2_log_file logger) { close(logger.file); - why2_free(logger.filename); + why2_deallocate(logger.filename); logger.filename = NULL; logger.file = INVALID_FILE; @@ -42,11 +42,11 @@ void why2_deallocate_decrypted_output(why2_decrypted_output output) { for (unsigned long i = 0; i < output.length; i++) { - why2_free(output.decrypted_text[i]); + why2_deallocate(output.decrypted_text[i]); } output.length = 0; - why2_free(output.decrypted_text); + why2_deallocate(output.decrypted_text); } why2_decrypted_output why2_decrypt_logger(why2_log_file logger) @@ -115,7 +115,7 @@ why2_decrypted_output why2_decrypt_logger(why2_log_file logger) } //DEALLOCATION - why2_free(rawContent); + why2_deallocate(rawContent); fclose(file); why2_deallocate_decrypted_output((why2_decrypted_output) { content, lines }); //fuck the system lmao