summaryrefslogtreecommitdiffstats
path: root/if-options.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-11-05 13:57:54 +0000
committerRoy Marples <roy@marples.name>2008-11-05 13:57:54 +0000
commite1caa8dbade9d653dec2172b5c052f1dbeaebb22 (patch)
tree841472da5b26b69879e83089635607b5a6b39129 /if-options.c
parent9783ceb17a8513b0ebcf5fc36d5a42cbd24f1c49 (diff)
downloaddhcpcd-e1caa8dbade9d653dec2172b5c052f1dbeaebb22.tar.xz
get_line now uses a single buffer, strips leading space and skips comments. This reduces malloc usage slightly and gives a cleaner API at the expense of a slight bss increase.
Diffstat (limited to 'if-options.c')
-rw-r--r--if-options.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/if-options.c b/if-options.c
index 3965119d..24bf5ad3 100644
--- a/if-options.c
+++ b/if-options.c
@@ -586,8 +586,7 @@ read_config(const char *file, const char *ifname)
{
struct if_options *ifo;
FILE *f;
- size_t len = 0;
- char *line, *option, *p, *buffer = NULL;
+ char *line, *option, *p;
int skip = 0;
/* Seed our default options */
@@ -612,18 +611,8 @@ read_config(const char *file, const char *ifname)
if (!f)
return ifo;
- while ((get_line(&buffer, &len, f))) {
- line = buffer;
- while ((option = strsep(&line, " \t")))
- if (*option != '\0')
- break;
- if (!option || *option == '\0' || *option == '#')
- continue;
- /* Trim leading whitespace */
- if (line) {
- while (*line != '\0' && (*line == ' ' || *line == '\t'))
- line++;
- }
+ while ((line = get_line(f))) {
+ option = strsep(&line, " \t");
/* Trim trailing whitespace */
if (line && *line) {
p = line + strlen(line) - 1;
@@ -646,7 +635,6 @@ read_config(const char *file, const char *ifname)
break;
}
}
- free(buffer);
fclose(f);
/* Terminate the encapsulated options */