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

Patrik Flykt patrik.flykt at linux.intel.com
Mon Dec 9 13:43:32 PST 2013


---
 src/dhcp/client.c            |   13 +++++++++++++
 src/systemd/sd-dhcp-client.h |    1 +
 2 files changed, 14 insertions(+)

diff --git a/src/dhcp/client.c b/src/dhcp/client.c
index d93cceb..2a479e4 100644
--- a/src/dhcp/client.c
+++ b/src/dhcp/client.c
@@ -961,6 +961,19 @@ int sd_dhcp_client_stop(sd_dhcp_client *client)
         return client_stop(client, DHCP_EVENT_STOP);
 }
 
+sd_dhcp_client *sd_dhcp_client_free(sd_dhcp_client *client)
+{
+        assert_return(client, NULL);
+
+        sd_dhcp_client_stop(client);
+
+        sd_event_unref(client->event);
+        free(client->req_opts);
+        free(client);
+
+        return NULL;
+}
+
 sd_dhcp_client *sd_dhcp_client_new(sd_event *event)
 {
         sd_dhcp_client *client;
diff --git a/src/systemd/sd-dhcp-client.h b/src/systemd/sd-dhcp-client.h
index 395c12d..fdc5b2d 100644
--- a/src/systemd/sd-dhcp-client.h
+++ b/src/systemd/sd-dhcp-client.h
@@ -57,6 +57,7 @@ int sd_dhcp_client_get_router(sd_dhcp_client *client, struct in_addr *addr);
 
 int sd_dhcp_client_stop(sd_dhcp_client *client);
 int sd_dhcp_client_start(sd_dhcp_client *client);
+sd_dhcp_client *sd_dhcp_client_free(sd_dhcp_client *client);
 sd_dhcp_client *sd_dhcp_client_new(sd_event *event);
 
 #endif
-- 
1.7.10.4



More information about the systemd-devel mailing list