https://bugzilla.balabit.com/show_bug.cgi?id=170 --- Comment #4 from Balazs Scheidler <bazsi@balabit.hu> 2012-03-31 21:58:31 --- I like the refactorization in the first patch, however I think it makes sense to keep the responsibility of the filename in the first function instead of moving the free into another function. I'm commiting the changes but I'm folding this into the first patch. Let me know if you have a problem with that. Thanks. diff --git a/lib/cfg-lexer.c b/lib/cfg-lexer.c index 5badde1..1dd1968 100644 --- a/lib/cfg-lexer.c +++ b/lib/cfg-lexer.c @@ -381,14 +381,13 @@ cfg_lexer_start_next_include(CfgLexer *self) } static gboolean -cfg_lexer_include_file_simple(CfgLexer *self, gchar *filename) +cfg_lexer_include_file_simple(CfgLexer *self, const gchar *filename) { CfgIncludeLevel *level; struct stat st; if (stat(filename, &st) < 0) { - g_free(filename); return FALSE; } @@ -459,7 +458,6 @@ cfg_lexer_include_file_simple(CfgLexer *self, gchar *filename) evt_tag_str("dir", filename), NULL); self->include_depth--; - g_free(filename); return TRUE; } } @@ -468,10 +466,8 @@ cfg_lexer_include_file_simple(CfgLexer *self, gchar *filename) g_assert(level->file.files == NULL); level->file.files = g_slist_prepend(level->file.files, g_strdup(filename)); } - g_free(filename); return cfg_lexer_start_next_include(self); drop_level: - g_free(filename); g_slist_foreach(level->file.files, (GFunc) g_free, NULL); g_slist_free(level->file.files); level->file.files = NULL; @@ -533,7 +529,6 @@ gboolean cfg_lexer_include_file(CfgLexer *self, const gchar *filename_) { struct stat st; - CfgIncludeLevel *level; gchar *filename; if (self->include_depth >= MAX_INCLUDE_DEPTH - 1) @@ -559,7 +554,13 @@ cfg_lexer_include_file(CfgLexer *self, const gchar *filename_) return FALSE; } else - return cfg_lexer_include_file_simple(self, filename); + { + gboolean result; + + result = cfg_lexer_include_file_simple(self, filename); + g_free(filename); + return result; + } } gboolean -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.