Fri, 27 May 2011 12:49:33 +0200
Fixed missing return statement in new_settings_t.
Added support for c++ compilers.
Added destroy_settings_t function
cline.c | file | annotate | diff | comparison | revisions | |
cline.h | file | annotate | diff | comparison | revisions | |
functions.h | file | annotate | diff | comparison | revisions |
--- a/cline.c Thu May 26 14:39:52 2011 +0200 +++ b/cline.c Fri May 27 12:49:33 2011 +0200 @@ -12,6 +12,15 @@ settings->recursive = false; settings->includeSuffixes = false; settings->matchesOnly = false; + + return settings; +} + +void destroy_settings_t(settings_t* settings) { + if (settings->suffixv != NULL) { + free(settings->suffixv); + } + free(settings); } void printHelpText(const char* prgName) { @@ -177,13 +186,13 @@ DIR *dir = opendir(directory); if (dir == NULL) { perror("Operation failed"); - free(settings->suffixv); - free(settings); + destroy_settings_t(settings); return 1; } // Scan directory int lines = scanDirectory(dir, 0, directory, settings); + closedir(dir); // Print double line and line count #ifdef _WIN32 @@ -201,8 +210,6 @@ printf("\n%74d lines\n", lines); #endif /* _WIN32 */ - closedir(dir); - free(settings->suffixv); - free(settings); + destroy_settings_t(settings); return 0; }
--- a/cline.h Thu May 26 14:39:52 2011 +0200 +++ b/cline.h Fri May 27 12:49:33 2011 +0200 @@ -16,8 +16,15 @@ bool matchesOnly; } settings_t; +#ifdef _cplusplus +extern "C" { +#endif settings_t* new_settings_t(); +void destroy_settings_t(settings_t*); -void printHelpText(const char* prgName); +void printHelpText(const char*); +#ifdef _cplusplus +} +#endif #endif /* _CLINE_H */
--- a/functions.h Thu May 26 14:39:52 2011 +0200 +++ b/functions.h Fri May 27 12:49:33 2011 +0200 @@ -1,9 +1,17 @@ #ifndef _CLINE_FUNCTIONS_H #define _CLINE_FUNCTIONS_H +#ifdef _cplusplus +extern "C" { +#endif + int checkArgument(const char*, const char*); bool testSuffix(char* filename, settings_t* settings); int scanDirectory(DIR *dir, const int spaces, char* currdir, settings_t* settings); -#endif /* V2_H */ +#ifdef _cplusplus +} +#endif + +#endif /* _CLINE_FUNCTIONS_H */