Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 990309de authored by SZCZEPANSKI Marin's avatar SZCZEPANSKI Marin
Browse files

Enfin une bonne gestion de la mémoire !

parent b190166c
No related branches found
No related tags found
No related merge requests found
......@@ -104,6 +104,7 @@ int main() {
}
free_commands(&inputs);
unload_map();
return 0;
}
......@@ -19,6 +19,8 @@ int read_input_file(const char* filename, CommandList* commands) {
Command* next = allocate_command(line, linesize);
prev_command->next = next;
prev_command = next;
} else {
free(line);
}
line = NULL;
}
......@@ -66,12 +68,14 @@ Command* allocate_command(char* command_buffer, size_t buffer_len) {
void free_command(Command* command) {
// Free next commands
if (command->next != NULL)
if (command->next != NULL) {
free_command(command->next);
}
// Free current command
free(command->command_buffer); // Free the buffer allocated by getline
if (command->args != NULL)
free(command->args);
free(command);
}
void free_commands(CommandList* commands) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment