# HG changeset patch # User Mike Becker # Date 1317852390 -7200 # Node ID 5f43f733cc124d9b4c860cabf71ac3f7745db203 # Parent bc9a0fefd892172bf8ab334366bbdf5d90e2f6a9 fixed suffixList realloc bug + added destroy_suffix_list_t diff -r bc9a0fefd892 -r 5f43f733cc12 settings.c --- a/settings.c Tue Sep 20 15:19:28 2011 +0200 +++ b/settings.c Thu Oct 06 00:06:30 2011 +0200 @@ -26,6 +26,6 @@ } void destroy_settings_t(settings_t* settings) { - free(settings->suffixList); + destroy_suffix_list_t(settings->suffixList); free(settings); } diff -r bc9a0fefd892 -r 5f43f733cc12 suffix_list.c --- a/suffix_list.c Tue Sep 20 15:19:28 2011 +0200 +++ b/suffix_list.c Thu Oct 06 00:06:30 2011 +0200 @@ -15,9 +15,16 @@ return suffixList; } +void destroy_suffix_list_t(suffix_list_t* list) { + if (list->items != NULL) { + free(list->items); + } + free(list); +} + void add_suffix(suffix_list_t* list, char* item) { char** reallocated_list = - realloc(list->items, sizeof(char*) * list->count + 1); + realloc(list->items, sizeof(char*) * (list->count + 1)); if (reallocated_list != NULL) { list->items = reallocated_list; list->items[list->count] = item; diff -r bc9a0fefd892 -r 5f43f733cc12 suffix_list.h --- a/suffix_list.h Tue Sep 20 15:19:28 2011 +0200 +++ b/suffix_list.h Thu Oct 06 00:06:30 2011 +0200 @@ -20,6 +20,7 @@ #endif suffix_list_t* new_suffix_list_t(); +void destroy_suffix_list_t(suffix_list_t*); void add_suffix(suffix_list_t*, char*); #ifdef _cplusplus