suffix_list.c

Fri, 16 Sep 2011 09:14:59 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 16 Sep 2011 09:14:59 +0200
changeset 12
902cb8d2053c
parent 11
06cbd0ec003d
child 17
5f43f733cc12
permissions
-rw-r--r--

removed dynamic programm name

10
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * suffix_list.c
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Created on: 15.09.2011
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 * Author: beckermi
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 */
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 #include "suffix_list.h"
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
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
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 suffixList->count = 0;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 suffixList->items = NULL;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 return suffixList;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 void add_suffix(suffix_list_t* list, char* item) {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 char** reallocated_list =
11
06cbd0ec003d Merge with 1dd63a32ffc486b71399045cf8443ec6ac9d7bf5
Mike Becker <universe@uap-core.de>
parents: 10
diff changeset
20 realloc(list->items, sizeof(char*) * list->count + 1);
10
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 if (reallocated_list != NULL) {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 list->items = reallocated_list;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 list->items[list->count] = item;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 list->count++;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27

mercurial