[systemd-devel] [PATCH 27/28] dhcp: Add function to free DHCP client data

Patrik Flykt patrik.flykt at linux.intel.com
Wed Nov 13 13:22:55 PST 2013


---
 src/dhcp/client.c |   11 +++++++++++
 src/dhcp/client.h |    2 ++
 2 files changed, 13 insertions(+)

diff --git a/src/dhcp/client.c b/src/dhcp/client.c
index 0144c70..a274549 100644
--- a/src/dhcp/client.c
+++ b/src/dhcp/client.c
@@ -994,6 +994,17 @@ int dhcp_client_stop(DHCPClient *client)
         return client_stop(client, DHCP_EVENT_STOP);
 }
 
+void dhcp_client_free(DHCPClient *client)
+{
+        if (!client)
+                return;
+
+        dhcp_client_stop(client);
+
+        free(client->req_opts);
+        free(client);
+}
+
 DHCPClient *dhcp_client_new(sd_event *event)
 {
         DHCPClient *client;
diff --git a/src/dhcp/client.h b/src/dhcp/client.h
index adb4443..55fec93 100644
--- a/src/dhcp/client.h
+++ b/src/dhcp/client.h
@@ -50,4 +50,6 @@ int dhcp_client_get_router(DHCPClient *client, struct in_addr *addr);
 
 int dhcp_client_start(DHCPClient *client);
 int dhcp_client_stop(DHCPClient *client);
+
+void dhcp_client_free(DHCPClient *client);
 DHCPClient *dhcp_client_new(sd_event *event);
-- 
1.7.10.4



More information about the systemd-devel mailing list