summaryrefslogtreecommitdiffstats
path: root/dhcp.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-04 08:48:06 +0000
committerRoy Marples <roy@marples.name>2008-09-04 08:48:06 +0000
commitb905fc787c1bcc537af52d407bf0bd350a7d5f7a (patch)
tree4bbf40ffd97c825e0cb08f7e503228c117b6fbf2 /dhcp.c
parentf0f4b8b6df73aaa57672c47a7f339b52db23e68f (diff)
downloaddhcpcd-b905fc787c1bcc537af52d407bf0bd350a7d5f7a.tar.xz
Only free the option buffer when debugging memory leaks.
Diffstat (limited to 'dhcp.c')
-rw-r--r--dhcp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/dhcp.c b/dhcp.c
index 0fb1f63f..004e2169 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -245,11 +245,13 @@ valid_length(uint8_t option, int dl, int *type)
return 0;
}
+#ifdef DEBUG_MEMORY
static void
free_option_buffer(void)
{
free(dhcp_opt_buffer);
}
+#endif
#define get_option_raw(dhcp, opt) get_option(dhcp, opt, NULL, NULL)
static const uint8_t *
@@ -270,7 +272,9 @@ get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len, int *type)
if (op) {
if (!dhcp_opt_buffer) {
dhcp_opt_buffer = xmalloc(sizeof(struct dhcp_message));
+#ifdef DEBUG_MEMORY
atexit(free_option_buffer);
+#endif
}
if (!bp)
bp = dhcp_opt_buffer;