diff --git a/fish_shell/fish_commands.c b/fish_shell/fish_commands.c index 8ed9bc3..96dc9b8 100644 --- a/fish_shell/fish_commands.c +++ b/fish_shell/fish_commands.c @@ -42,7 +42,7 @@ int fishHelp(WordArray *args) { int i; printf("Bartuccio Antoine, Amalvy Arthur, Yann Chevanton\n"); printf("Tape tes putains de noms de programmes et tes arguments de merde et tabasse ENTER !\n"); - printf("Les commandes suivantes sont internes :\nls"); + printf("Les commandes suivantes sont internes :\n"); for (i=0; i < getNbBuiltins(); i++){ printf("\t%s\n", builtinCommandsStr[i]); } diff --git a/fish_shell/fish_core.c b/fish_shell/fish_core.c index 2f3e9c7..3269ea0 100644 --- a/fish_shell/fish_core.c +++ b/fish_shell/fish_core.c @@ -51,6 +51,7 @@ WordArray * split(char *string, char *separator){ int array_size = countSeparators(string, separator) + 1; WordArray *tokens = (WordArray*) malloc(sizeof(WordArray)); char *to_delete = strdup(string); + char *to_delete_bak = to_delete; char *token = NULL; int i = 0; @@ -70,7 +71,7 @@ WordArray * split(char *string, char *separator){ i++; } - free(to_delete); + free(to_delete_bak); return tokens; } @@ -81,6 +82,7 @@ void freeWordArray(WordArray *array) { for (i = 0; i < array->size; i++) { free(array->words[i]); } + free(array->words); free(array); } @@ -141,6 +143,13 @@ Settings *getSettings() { return s; } +void freeSettings(Settings *settings){ + if (settings != NULL){ + free(settings->PS1); + free(settings); + } +} + int fishLoad(WordArray *array) { pid_t pid; int status; diff --git a/fish_shell/fish_core.h b/fish_shell/fish_core.h index 0522e2c..6173064 100644 --- a/fish_shell/fish_core.h +++ b/fish_shell/fish_core.h @@ -17,6 +17,7 @@ void freeWordArray(WordArray *array); /* Settings functions */ Settings * getSettings(); +void freeSettings(Settings *settings); /* General purpose functions */ diff --git a/main.c b/main.c index 9abfbf9..8c76cae 100644 --- a/main.c +++ b/main.c @@ -6,8 +6,7 @@ int main() { /* todo load config file */ Settings *s = getSettings(); fishLoop(s); - free(s->PS1); - free(s); + freeSettings(s); return EXIT_SUCCESS; }