Thu, 02 Feb 2012 16:55:51 +0100
fixed author note
10 | 1 | /* |
19
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
2 | * string_list.c |
10 | 3 | * |
4 | * Created on: 15.09.2011 | |
20
43725438ac50
Changed author comments + added signatures for upcomming bfile heuristics
Mike Becker <universe@uap-core.de>
parents:
19
diff
changeset
|
5 | * Author: Mike |
10 | 6 | */ |
7 | ||
19
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
8 | #include "string_list.h" |
10 | 9 | |
19
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
10 | string_list_t* new_string_list_t() { |
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
11 | string_list_t* stringList = malloc(sizeof(string_list_t)); |
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
12 | stringList->count = 0; |
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
13 | stringList->items = NULL; |
10 | 14 | |
19
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
15 | return stringList; |
10 | 16 | } |
17 | ||
19
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
18 | void destroy_string_list_t(string_list_t* list) { |
17
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 | |
19
8bac9fd0629d
generalized suffix_list to string_list
Mike Becker <universe@uap-core.de>
parents:
17
diff
changeset
|
25 | void add_string(string_list_t* list, char* item) { |
10 | 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 |