]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Only free the option buffer when debugging memory leaks.
authorRoy Marples <roy@marples.name>
Thu, 4 Sep 2008 08:48:06 +0000 (08:48 +0000)
committerRoy Marples <roy@marples.name>
Thu, 4 Sep 2008 08:48:06 +0000 (08:48 +0000)
dhcp.c

diff --git a/dhcp.c b/dhcp.c
index 0fb1f63f0e17fe6f0877c20dbfb7d93da7fa99e6..004e21693cd1302faecf91cee0fdc1ee5442e68f 100644 (file)
--- 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;