suffix_list.c

changeset 17
5f43f733cc12
parent 11
06cbd0ec003d
equal deleted inserted replaced
16:bc9a0fefd892 17:5f43f733cc12
13 suffixList->items = NULL; 13 suffixList->items = NULL;
14 14
15 return suffixList; 15 return suffixList;
16 } 16 }
17 17
18 void destroy_suffix_list_t(suffix_list_t* list) {
19 if (list->items != NULL) {
20 free(list->items);
21 }
22 free(list);
23 }
24
18 void add_suffix(suffix_list_t* list, char* item) { 25 void add_suffix(suffix_list_t* list, char* item) {
19 char** reallocated_list = 26 char** reallocated_list =
20 realloc(list->items, sizeof(char*) * list->count + 1); 27 realloc(list->items, sizeof(char*) * (list->count + 1));
21 if (reallocated_list != NULL) { 28 if (reallocated_list != NULL) {
22 list->items = reallocated_list; 29 list->items = reallocated_list;
23 list->items[list->count] = item; 30 list->items[list->count] = item;
24 list->count++; 31 list->count++;
25 } 32 }

mercurial