Thu, 09 Feb 2012 15:56:18 +0100
allow parallel use of -s and -S
universe@10 | 1 | /* |
universe@19 | 2 | * string_list.c |
universe@10 | 3 | * |
universe@10 | 4 | * Created on: 15.09.2011 |
universe@20 | 5 | * Author: Mike |
universe@10 | 6 | */ |
universe@10 | 7 | |
universe@19 | 8 | #include "string_list.h" |
universe@10 | 9 | |
universe@19 | 10 | string_list_t* new_string_list_t() { |
universe@19 | 11 | string_list_t* stringList = malloc(sizeof(string_list_t)); |
universe@19 | 12 | stringList->count = 0; |
universe@19 | 13 | stringList->items = NULL; |
universe@10 | 14 | |
universe@19 | 15 | return stringList; |
universe@10 | 16 | } |
universe@10 | 17 | |
universe@19 | 18 | void destroy_string_list_t(string_list_t* list) { |
universe@17 | 19 | if (list->items != NULL) { |
universe@17 | 20 | free(list->items); |
universe@17 | 21 | } |
universe@17 | 22 | free(list); |
universe@17 | 23 | } |
universe@17 | 24 | |
universe@19 | 25 | void add_string(string_list_t* list, char* item) { |
universe@10 | 26 | char** reallocated_list = |
universe@17 | 27 | realloc(list->items, sizeof(char*) * (list->count + 1)); |
universe@10 | 28 | if (reallocated_list != NULL) { |
universe@10 | 29 | list->items = reallocated_list; |
universe@10 | 30 | list->items[list->count] = item; |
universe@10 | 31 | list->count++; |
universe@10 | 32 | } |
universe@10 | 33 | } |
universe@10 | 34 |