diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2013-07-22 08:46:52 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2013-08-21 03:06:41 +0200 |
commit | bf1c8e3a3c8d8becfb1f8c990d29ff459271b707 (patch) | |
tree | 248d54b0b95c9899aa0c6ed659310f90370e5b23 | |
parent | 3d2c8e1fd0e2b1c74f82c6b2b667964768ea4cb0 (diff) | |
download | pacman-bf1c8e3a3c8d8becfb1f8c990d29ff459271b707.tar.gz pacman-bf1c8e3a3c8d8becfb1f8c990d29ff459271b707.tar.xz |
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 <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/pacman/ini.c | 10 |
1 files changed, 5 insertions, 5 deletions
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: */ |