1 #include "cline.h" |
1 #include "cline.h" |
2 #include "functions.h" |
2 #include "functions.h" |
3 |
3 |
4 suffix_list_t* new_suffix_list_t() { |
4 suffix_list_t* new_suffix_list_t() { |
5 suffix_list_t* suffixList = malloc(sizeof(suffix_list_t*)); |
5 suffix_list_t* suffixList = malloc(sizeof(suffix_list_t)); |
6 suffixList->count = 0; |
6 suffixList->count = 0; |
7 suffixList->items = NULL; |
7 suffixList->items = NULL; |
8 } |
8 |
9 |
9 return suffixList; |
10 void destroy_suffix_list_t(suffix_list_t* list) { |
|
11 while (--list->count >= 0) { |
|
12 free(list->items[list->count]); |
|
13 } |
|
14 free(list); |
|
15 } |
10 } |
16 |
11 |
17 void add_suffix(suffix_list_t* list, char* item) { |
12 void add_suffix(suffix_list_t* list, char* item) { |
18 char** reallocated_list = |
13 char** reallocated_list = |
19 realloc(list->items, sizeof(char**) * list->count + 1); |
14 realloc(list->items, sizeof(char*) * list->count + 1); |
20 if (reallocated_list != NULL) { |
15 if (reallocated_list != NULL) { |
21 list->items = reallocated_list; |
16 list->items = reallocated_list; |
22 list->items[list->count] = item; |
17 list->items[list->count] = item; |
23 list->count++; |
18 list->count++; |
24 } |
19 } |
25 } |
20 } |
26 |
21 |
27 settings_t* new_settings_t() { |
22 settings_t* new_settings_t() { |
28 settings_t *settings = malloc(sizeof(settings_t*)); |
23 settings_t *settings = malloc(sizeof(settings_t)); |
29 if (settings != NULL) { |
24 if (settings != NULL) { |
30 #ifdef _WIN32 |
25 #ifdef _WIN32 |
31 settings->fileSeparator = '\\'; |
26 settings->fileSeparator = '\\'; |
32 #else |
27 #else |
33 settings->fileSeparator = '/'; |
28 settings->fileSeparator = '/'; |