diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6706c60..3b4598a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,6 +7,7 @@ "command": "/usr/bin/gcc", "args": [ "-g", + "-Wall", "main.c", "-o", "a.out" @@ -23,6 +24,7 @@ "command": "/usr/bin/gcc", "args": [ "-g", + "-Wall", "main_logging.c", "-o", "a.out" diff --git a/main.c b/main.c index 933be2e..2a626ed 100644 --- a/main.c +++ b/main.c @@ -47,9 +47,11 @@ int LogCommandHistory(char* buf, char** command_log, int* n) { return 0; } -void FreeCommandHistory(char** command_log, int n) { - for (int i = 0; i < n; i++) { - free(command_log[i]); +void FreeCommandHistory(char** command_log) { + for (int i = 0; i < HISTORY_SIZE; i++) { + if (command_log[i] != NULL) { + free(command_log[i]); + } } } @@ -270,6 +272,6 @@ int main() { } } - FreeCommandHistory(command_log, n); + FreeCommandHistory(command_log); return 0; } \ No newline at end of file