renamed why2_free to why2_deallocate

This commit is contained in:
Václav Šmejkal 2023-02-05 18:25:42 +01:00
parent 1285f52b67
commit 6e7ea8b6f5
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
9 changed files with 30 additions and 30 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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();

View File

@ -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;

View File

@ -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
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -32,7 +32,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
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