Sat, 15 Oct 2011 14:52:12 +0200
Increased warning level, fixed resulting warnings, changed std form c99 to gnu99
10 | 1 | /* |
2 | * suffix_list.c | |
3 | * | |
4 | * Created on: 15.09.2011 | |
5 | * Author: beckermi | |
6 | */ | |
7 | ||
8 | #include "suffix_list.h" | |
9 | ||
10 | suffix_list_t* new_suffix_list_t() { | |
11
06cbd0ec003d
Merge with 1dd63a32ffc486b71399045cf8443ec6ac9d7bf5
Mike Becker <universe@uap-core.de>
parents:
10
diff
changeset
|
11 | suffix_list_t* suffixList = malloc(sizeof(suffix_list_t)); |
10 | 12 | suffixList->count = 0; |
13 | suffixList->items = NULL; | |
14 | ||
15 | return suffixList; | |
16 | } | |
17 | ||
17
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
18 | void destroy_suffix_list_t(suffix_list_t* list) { |
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
19 | if (list->items != NULL) { |
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
20 | free(list->items); |
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
21 | } |
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
22 | free(list); |
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
23 | } |
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
24 | |
10 | 25 | void add_suffix(suffix_list_t* list, char* item) { |
26 | char** reallocated_list = | |
17
5f43f733cc12
fixed suffixList realloc bug + added destroy_suffix_list_t
Mike Becker <universe@uap-core.de>
parents:
11
diff
changeset
|
27 | realloc(list->items, sizeof(char*) * (list->count + 1)); |
10 | 28 | if (reallocated_list != NULL) { |
29 | list->items = reallocated_list; | |
30 | list->items[list->count] = item; | |
31 | list->count++; | |
32 | } | |
33 | } | |
34 |