Thu, 06 Oct 2011 00:06:30 +0200
fixed suffixList realloc bug + added destroy_suffix_list_t
settings.c | file | annotate | diff | comparison | revisions | |
suffix_list.c | file | annotate | diff | comparison | revisions | |
suffix_list.h | file | annotate | diff | comparison | revisions |
--- 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); }
--- 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;