diff options
| author | Roy Marples <roy@marples.name> | 2008-11-05 13:57:54 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-11-05 13:57:54 +0000 |
| commit | e1caa8dbade9d653dec2172b5c052f1dbeaebb22 (patch) | |
| tree | 841472da5b26b69879e83089635607b5a6b39129 /if-linux.c | |
| parent | 9783ceb17a8513b0ebcf5fc36d5a42cbd24f1c49 (diff) | |
| download | dhcpcd-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-linux.c')
| -rw-r--r-- | if-linux.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -431,18 +431,15 @@ struct interface * discover_interfaces(int argc, char * const *argv) { FILE *f; - char *buffer = NULL, *p; - size_t len = 0, ln = 0, n; + char *p; + size_t ln = 0, n; int i; struct interface *ifs = NULL, *ifp, *ifl; if ((f = fopen("/proc/net/dev", "r"))) { - while (get_line(&buffer, &len, f)) { + while (p = get_line(f)) { if (++ln < 2) continue; - p = buffer; - while (isspace((unsigned int)*p)) - p++; n = strcspn(p, ": \t"); p[n]= '\0'; ifl = NULL; @@ -479,7 +476,6 @@ discover_interfaces(int argc, char * const *argv) } } fclose(f); - free(buffer); } return ifs; } |
