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

Patrik Flykt patrik.flykt at linux.intel.com
Sun Nov 24 23:13:42 PST 2013


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

diff --git a/src/dhcp/client.c b/src/dhcp/client.c
index fb28b7b..fc4c791 100644
--- a/src/dhcp/client.c
+++ b/src/dhcp/client.c
@@ -945,6 +945,18 @@ int sd_dhcp_client_stop(DHCPClient *client)
         return client_stop(client, DHCP_EVENT_STOP);
 }
 
+DHCPClient *sd_dhcp_client_free(DHCPClient *client)
+{
+        assert_return(client, NULL);
+
+        sd_dhcp_client_stop(client);
+
+        free(client->req_opts);
+        free(client);
+
+        return NULL;
+}
+
 DHCPClient *sd_dhcp_client_new(sd_event *event)
 {
         DHCPClient *client;
diff --git a/src/systemd/sd-dhcp-client.h b/src/systemd/sd-dhcp-client.h
index c3d2a48..c3061ae 100644
--- a/src/systemd/sd-dhcp-client.h
+++ b/src/systemd/sd-dhcp-client.h
@@ -53,4 +53,5 @@ int sd_dhcp_client_get_router(DHCPClient *client, struct in_addr *addr);
 
 int sd_dhcp_client_stop(DHCPClient *client);
 int sd_dhcp_client_start(DHCPClient *client);
+DHCPClient *sd_dhcp_client_free(DHCPClient *client);
 DHCPClient *sd_dhcp_client_new(sd_event *event);
-- 
1.7.10.4



More information about the systemd-devel mailing list