From bf1c8e3a3c8d8becfb1f8c990d29ff459271b707 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Mon, 22 Jul 2013 02:46:52 -0400 Subject: ini.c: reuse line buffer By the time we make the recursive call we have already finished with the line buffer, making it safe to reuse. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/ini.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/pacman/ini.c b/src/pacman/ini.c index 4d25f58c..2c73d936 100644 --- a/src/pacman/ini.c +++ b/src/pacman/ini.c @@ -34,16 +34,16 @@ * @param cb callback for key/value pairs * @param data caller defined data to be passed to the callback * @param section_name the name of the current section + * @param line buffer to read into, must be at least PATH_MAX long * @param depth recursion depth, should initially be 0 * * @return 0 on success, 1 on parsing errors, the callback return value * otherwise */ static int _parse_ini(const char *file, ini_parser_fn cb, void *data, - char **section_name, int depth) + char **section_name, char *line, int depth) { FILE *fp = NULL; - char line[PATH_MAX]; int linenum = 0; int ret = 0; const int max_depth = 10; @@ -154,7 +154,7 @@ static int _parse_ini(const char *file, ini_parser_fn cb, void *data, pm_printf(ALPM_LOG_DEBUG, "config file %s, line %d: including %s\n", file, linenum, globbuf.gl_pathv[gindex]); _parse_ini(globbuf.gl_pathv[gindex], cb, data, - section_name, depth + 1); + section_name, line, depth + 1); } break; } @@ -204,8 +204,8 @@ cleanup: */ int parse_ini(const char *file, ini_parser_fn cb, void *data) { - char *section_name = NULL; - return _parse_ini(file, cb, data, §ion_name, 0); + char *section_name = NULL, line[PATH_MAX]; + return _parse_ini(file, cb, data, §ion_name, line, 0); } /* vim: set ts=2 sw=2 noet: */ -- cgit v1.2.3-24-g4f1b