summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-05 14:16:53 +0000
committerRoy Marples <roy@marples.name>2008-09-05 14:16:53 +0000
commitfca060b851b96d6e82d13306df83322ea1d08128 (patch)
tree5c025c3faf0c8bcce15440476407e21815115978 /dhcpcd.c
parent9f7780b07bd3216da3fb83f95b9976e4fd257484 (diff)
downloaddhcpcd-fca060b851b96d6e82d13306df83322ea1d08128.tar.xz
Save more memory, malloc the pidfile.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index a42aa024..84468dd5 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -70,7 +70,7 @@ static char **ifv = NULL;
static int ifc = 0;
static int linkfd = -1;
static char *cffile = NULL;
-static char pidfile[PATH_MAX] = { '\0' };
+static char *pidfile;
static struct interface *ifaces = NULL;
struct dhcp_op {
@@ -150,6 +150,9 @@ cleanup(void)
close(pidfd);
unlink(pidfile);
}
+#ifdef DEBUG_MEMORY
+ free(pidfile);
+#endif
}
_noreturn void
@@ -962,6 +965,7 @@ main(int argc, char **argv)
struct if_options *ifo;
struct interface *iface;
int opt, oi = 0, signal_fd, sig = 0, i, control_fd;
+ size_t len;
pid_t pid;
struct timespec ts;
@@ -1028,10 +1032,12 @@ main(int argc, char **argv)
/* If we have any other args, we should run as a single dhcpcd instance
* for that interface. */
- if (optind == argc - 1 && !(options & DHCPCD_TEST))
- snprintf(pidfile, sizeof(pidfile), PIDFILE, "-", argv[optind]);
- else {
- snprintf(pidfile, sizeof(pidfile), PIDFILE, "", "");
+ len = strlen(PIDFILE) + IF_NAMESIZE + 2;
+ pidfile = xmalloc(len);
+ if (optind == argc - 1 && !(options & DHCPCD_TEST)) {
+ snprintf(pidfile, len, PIDFILE, "-", argv[optind]);
+ } else {
+ snprintf(pidfile, len, PIDFILE, "", "");
options |= DHCPCD_MASTER;
}