diff --git a/src/list.c b/src/list.c index 76ce53a..f5c8256 100644 --- a/src/list.c +++ b/src/list.c @@ -1,4 +1,7 @@ #include "../includes/list.h" +#include +#include +#include List* CreateList() { List *new = malloc(sizeof(List)); @@ -16,7 +19,12 @@ int AddListItem(char *value, List* list) { list->capacity = list->capacity * 2; } - list->root[list->size] = value; + unsigned long valueLength = strlen(value) + 1; //Plus one for the null byte. + + char* item = malloc(valueLength); + strncpy(item, value, valueLength); + + list->root[list->size] = item; list->size++; return 0;