Sun, 16 Oct 2011 12:20:52 +0200
generalized suffix_list to string_list
cline.c | file | annotate | diff | comparison | revisions | |
settings.c | file | annotate | diff | comparison | revisions | |
settings.h | file | annotate | diff | comparison | revisions | |
string_list.c | file | annotate | diff | comparison | revisions | |
string_list.h | file | annotate | diff | comparison | revisions | |
suffix_list.c | file | annotate | diff | comparison | revisions | |
suffix_list.h | file | annotate | diff | comparison | revisions |
1.1 --- a/cline.c Sat Oct 15 14:52:12 2011 +0200 1.2 +++ b/cline.c Sun Oct 16 12:20:52 2011 +0200 1.3 @@ -126,7 +126,7 @@ 1.4 // Find tokens 1.5 char* finder = strtok(suffix, ","); 1.6 while (finder != NULL) { 1.7 - add_suffix(settings->suffixList, finder); 1.8 + add_string(settings->suffixList, finder); 1.9 finder = strtok(NULL, ","); 1.10 } 1.11
2.1 --- a/settings.c Sat Oct 15 14:52:12 2011 +0200 2.2 +++ b/settings.c Sun Oct 16 12:20:52 2011 +0200 2.3 @@ -18,7 +18,7 @@ 2.4 settings->recursive = false; 2.5 settings->includeSuffixes = false; 2.6 settings->matchesOnly = false; 2.7 - settings->suffixList = new_suffix_list_t(); 2.8 + settings->suffixList = new_string_list_t(); 2.9 settings->verbose = true; 2.10 } 2.11 2.12 @@ -26,6 +26,6 @@ 2.13 } 2.14 2.15 void destroy_settings_t(settings_t* settings) { 2.16 - destroy_suffix_list_t(settings->suffixList); 2.17 + destroy_string_list_t(settings->suffixList); 2.18 free(settings); 2.19 }
3.1 --- a/settings.h Sat Oct 15 14:52:12 2011 +0200 3.2 +++ b/settings.h Sun Oct 16 12:20:52 2011 +0200 3.3 @@ -9,11 +9,11 @@ 3.4 #define SETTINGS_H_ 3.5 3.6 #include "stdinc.h" 3.7 -#include "suffix_list.h" 3.8 +#include "string_list.h" 3.9 3.10 typedef struct _settings { 3.11 char fileSeparator; 3.12 - suffix_list_t* suffixList; 3.13 + string_list_t* suffixList; 3.14 bool recursive; 3.15 bool includeSuffixes; 3.16 bool matchesOnly;
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/string_list.c Sun Oct 16 12:20:52 2011 +0200 4.3 @@ -0,0 +1,34 @@ 4.4 +/* 4.5 + * string_list.c 4.6 + * 4.7 + * Created on: 15.09.2011 4.8 + * Author: beckermi 4.9 + */ 4.10 + 4.11 +#include "string_list.h" 4.12 + 4.13 +string_list_t* new_string_list_t() { 4.14 + string_list_t* stringList = malloc(sizeof(string_list_t)); 4.15 + stringList->count = 0; 4.16 + stringList->items = NULL; 4.17 + 4.18 + return stringList; 4.19 +} 4.20 + 4.21 +void destroy_string_list_t(string_list_t* list) { 4.22 + if (list->items != NULL) { 4.23 + free(list->items); 4.24 + } 4.25 + free(list); 4.26 +} 4.27 + 4.28 +void add_string(string_list_t* list, char* item) { 4.29 + char** reallocated_list = 4.30 + realloc(list->items, sizeof(char*) * (list->count + 1)); 4.31 + if (reallocated_list != NULL) { 4.32 + list->items = reallocated_list; 4.33 + list->items[list->count] = item; 4.34 + list->count++; 4.35 + } 4.36 +} 4.37 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/string_list.h Sun Oct 16 12:20:52 2011 +0200 5.3 @@ -0,0 +1,30 @@ 5.4 +/* 5.5 + * string_list.h 5.6 + * 5.7 + * Created on: 15.09.2011 5.8 + * Author: beckermi 5.9 + */ 5.10 + 5.11 +#ifndef STRING_LIST_H_ 5.12 +#define STRING_LIST_H_ 5.13 + 5.14 +#include "stdinc.h" 5.15 + 5.16 +typedef struct _string_list { 5.17 + int count; 5.18 + char** items; 5.19 +} string_list_t; 5.20 + 5.21 +#ifdef _cplusplus 5.22 +extern "C" { 5.23 +#endif 5.24 + 5.25 +string_list_t* new_string_list_t(); 5.26 +void destroy_string_list_t(string_list_t*); 5.27 +void add_string(string_list_t*, char*); 5.28 + 5.29 +#ifdef _cplusplus 5.30 +} 5.31 +#endif 5.32 + 5.33 +#endif /* STRING_LIST_H_ */
6.1 --- a/suffix_list.c Sat Oct 15 14:52:12 2011 +0200 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,34 +0,0 @@ 6.4 -/* 6.5 - * suffix_list.c 6.6 - * 6.7 - * Created on: 15.09.2011 6.8 - * Author: beckermi 6.9 - */ 6.10 - 6.11 -#include "suffix_list.h" 6.12 - 6.13 -suffix_list_t* new_suffix_list_t() { 6.14 - suffix_list_t* suffixList = malloc(sizeof(suffix_list_t)); 6.15 - suffixList->count = 0; 6.16 - suffixList->items = NULL; 6.17 - 6.18 - return suffixList; 6.19 -} 6.20 - 6.21 -void destroy_suffix_list_t(suffix_list_t* list) { 6.22 - if (list->items != NULL) { 6.23 - free(list->items); 6.24 - } 6.25 - free(list); 6.26 -} 6.27 - 6.28 -void add_suffix(suffix_list_t* list, char* item) { 6.29 - char** reallocated_list = 6.30 - realloc(list->items, sizeof(char*) * (list->count + 1)); 6.31 - if (reallocated_list != NULL) { 6.32 - list->items = reallocated_list; 6.33 - list->items[list->count] = item; 6.34 - list->count++; 6.35 - } 6.36 -} 6.37 -
7.1 --- a/suffix_list.h Sat Oct 15 14:52:12 2011 +0200 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,30 +0,0 @@ 7.4 -/* 7.5 - * suffix_list.h 7.6 - * 7.7 - * Created on: 15.09.2011 7.8 - * Author: beckermi 7.9 - */ 7.10 - 7.11 -#ifndef SUFFIX_LIST_H_ 7.12 -#define SUFFIX_LIST_H_ 7.13 - 7.14 -#include "stdinc.h" 7.15 - 7.16 -typedef struct _suffix_list { 7.17 - int count; 7.18 - char** items; 7.19 -} suffix_list_t; 7.20 - 7.21 -#ifdef _cplusplus 7.22 -extern "C" { 7.23 -#endif 7.24 - 7.25 -suffix_list_t* new_suffix_list_t(); 7.26 -void destroy_suffix_list_t(suffix_list_t*); 7.27 -void add_suffix(suffix_list_t*, char*); 7.28 - 7.29 -#ifdef _cplusplus 7.30 -} 7.31 -#endif 7.32 - 7.33 -#endif /* SUFFIX_LIST_H_ */