From: Roy Marples Date: Thu, 4 Sep 2008 08:48:06 +0000 (+0000) Subject: Only free the option buffer when debugging memory leaks. X-Git-Tag: v5.0.0~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b905fc787c1bcc537af52d407bf0bd350a7d5f7a;p=thirdparty%2Fdhcpcd.git Only free the option buffer when debugging memory leaks. --- 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;