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

En route vers le 0 leak memory

This commit is contained in:
Antoine Bartuccio 2017-05-17 18:48:16 +02:00
parent 774161d7ff
commit 34b8cbe3cf
2 changed files with 5 additions and 4 deletions

View File

@ -44,8 +44,10 @@ include_directories(
"${source_dir}/googlemock/include" "${source_dir}/googlemock/include"
) )
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "-Wall -Werror -pedantic -fpic -Wextra -Wshadow") set(CMAKE_C_FLAGS "-Wall -Werror -pedantic -fpic -Wextra -Wshadow")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FALGS} -g")
set(SOURCE_FILES fish_shell/main.c fish_shell/fish_types.h fish_shell/fish_core.h fish_shell/fish_core.c fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_globbing.c fish_shell/fish_globbing.h fish_shell/fish_utils.c fish_shell/fish_utils.h) set(SOURCE_FILES fish_shell/main.c fish_shell/fish_types.h fish_shell/fish_core.h fish_shell/fish_core.c fish_shell/fish_commands.c fish_shell/fish_commands.h fish_shell/fish_globbing.c fish_shell/fish_globbing.h fish_shell/fish_utils.c fish_shell/fish_utils.h)
add_executable(fish ${SOURCE_FILES}) add_executable(fish ${SOURCE_FILES})

View File

@ -110,12 +110,11 @@ WordArray *wordListToWordArray(WordList *list) {
if (array->words == NULL) crash(); if (array->words == NULL) crash();
while (current != NULL){ while (current != NULL){
array->words[i] = current->word; array->words[i] = strdup(current->word);
current->word = NULL;
current = current->next; current = current->next;
i++; i++;
} }
array->words[i] = NULL; array->words[array->size] = NULL;
} }
freeWordList(list); freeWordList(list);
@ -125,7 +124,7 @@ WordArray *wordListToWordArray(WordList *list) {
WordList *wordArrayToWordList(WordArray *array) { WordList *wordArrayToWordList(WordArray *array) {
WordList *list = createWordList(); WordList *list = createWordList();
int i = 0; int i;
for (i=0; i<array->size; i++) for (i=0; i<array->size; i++)
addWordList(list, array->words[i]); addWordList(list, array->words[i]);