1
0
mirror of https://gitlab.com/klmp200/fish.git synced 2024-11-21 16:23:20 +00:00

Plus de fuites de mémoire

This commit is contained in:
Antoine Bartuccio 2017-05-15 12:32:00 +02:00
parent 5cef74481c
commit a826969c3e
4 changed files with 13 additions and 4 deletions

View File

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

View File

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

View File

@ -17,6 +17,7 @@ void freeWordArray(WordArray *array);
/* Settings functions */
Settings * getSettings();
void freeSettings(Settings *settings);
/* General purpose functions */

3
main.c
View File

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