# HG changeset patch # User Mike Becker # Date 1318760452 -7200 # Node ID 8bac9fd0629dfd9b43718074ac9d048373e233fa # Parent cae1294702aa425512283dbbd1bf2ad2c271bee9 generalized suffix_list to string_list diff -r cae1294702aa -r 8bac9fd0629d cline.c --- a/cline.c Sat Oct 15 14:52:12 2011 +0200 +++ b/cline.c Sun Oct 16 12:20:52 2011 +0200 @@ -126,7 +126,7 @@ // Find tokens char* finder = strtok(suffix, ","); while (finder != NULL) { - add_suffix(settings->suffixList, finder); + add_string(settings->suffixList, finder); finder = strtok(NULL, ","); } diff -r cae1294702aa -r 8bac9fd0629d settings.c --- a/settings.c Sat Oct 15 14:52:12 2011 +0200 +++ b/settings.c Sun Oct 16 12:20:52 2011 +0200 @@ -18,7 +18,7 @@ settings->recursive = false; settings->includeSuffixes = false; settings->matchesOnly = false; - settings->suffixList = new_suffix_list_t(); + settings->suffixList = new_string_list_t(); settings->verbose = true; } @@ -26,6 +26,6 @@ } void destroy_settings_t(settings_t* settings) { - destroy_suffix_list_t(settings->suffixList); + destroy_string_list_t(settings->suffixList); free(settings); } diff -r cae1294702aa -r 8bac9fd0629d settings.h --- a/settings.h Sat Oct 15 14:52:12 2011 +0200 +++ b/settings.h Sun Oct 16 12:20:52 2011 +0200 @@ -9,11 +9,11 @@ #define SETTINGS_H_ #include "stdinc.h" -#include "suffix_list.h" +#include "string_list.h" typedef struct _settings { char fileSeparator; - suffix_list_t* suffixList; + string_list_t* suffixList; bool recursive; bool includeSuffixes; bool matchesOnly; diff -r cae1294702aa -r 8bac9fd0629d string_list.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/string_list.c Sun Oct 16 12:20:52 2011 +0200 @@ -0,0 +1,34 @@ +/* + * string_list.c + * + * Created on: 15.09.2011 + * Author: beckermi + */ + +#include "string_list.h" + +string_list_t* new_string_list_t() { + string_list_t* stringList = malloc(sizeof(string_list_t)); + stringList->count = 0; + stringList->items = NULL; + + return stringList; +} + +void destroy_string_list_t(string_list_t* list) { + if (list->items != NULL) { + free(list->items); + } + free(list); +} + +void add_string(string_list_t* list, char* item) { + char** reallocated_list = + realloc(list->items, sizeof(char*) * (list->count + 1)); + if (reallocated_list != NULL) { + list->items = reallocated_list; + list->items[list->count] = item; + list->count++; + } +} + diff -r cae1294702aa -r 8bac9fd0629d string_list.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/string_list.h Sun Oct 16 12:20:52 2011 +0200 @@ -0,0 +1,30 @@ +/* + * string_list.h + * + * Created on: 15.09.2011 + * Author: beckermi + */ + +#ifndef STRING_LIST_H_ +#define STRING_LIST_H_ + +#include "stdinc.h" + +typedef struct _string_list { + int count; + char** items; +} string_list_t; + +#ifdef _cplusplus +extern "C" { +#endif + +string_list_t* new_string_list_t(); +void destroy_string_list_t(string_list_t*); +void add_string(string_list_t*, char*); + +#ifdef _cplusplus +} +#endif + +#endif /* STRING_LIST_H_ */ diff -r cae1294702aa -r 8bac9fd0629d suffix_list.c --- a/suffix_list.c Sat Oct 15 14:52:12 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * suffix_list.c - * - * Created on: 15.09.2011 - * Author: beckermi - */ - -#include "suffix_list.h" - -suffix_list_t* new_suffix_list_t() { - suffix_list_t* suffixList = malloc(sizeof(suffix_list_t)); - suffixList->count = 0; - suffixList->items = NULL; - - 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)); - if (reallocated_list != NULL) { - list->items = reallocated_list; - list->items[list->count] = item; - list->count++; - } -} - diff -r cae1294702aa -r 8bac9fd0629d suffix_list.h --- a/suffix_list.h Sat Oct 15 14:52:12 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * suffix_list.h - * - * Created on: 15.09.2011 - * Author: beckermi - */ - -#ifndef SUFFIX_LIST_H_ -#define SUFFIX_LIST_H_ - -#include "stdinc.h" - -typedef struct _suffix_list { - int count; - char** items; -} suffix_list_t; - -#ifdef _cplusplus -extern "C" { -#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 -} -#endif - -#endif /* SUFFIX_LIST_H_ */