vpp-swan: fix memory leaks
This patch fix the memory leaks discovered in the current
implementation, inlcuding expired data, spd dump, and host names.
Type: fix
Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com>
Change-Id: I3794f5db3c58d1e78df25f242c91e7a67363de53
diff --git a/extras/strongswan/vpp_sswan/kernel_vpp_net.c b/extras/strongswan/vpp_sswan/kernel_vpp_net.c
index a29a7c6..1ed5843 100644
--- a/extras/strongswan/vpp_sswan/kernel_vpp_net.c
+++ b/extras/strongswan/vpp_sswan/kernel_vpp_net.c
@@ -545,6 +545,7 @@
vl_api_ip_address_details_t *rmp, *tmp;
linked_list_t *addrs;
host_t *host;
+ enumerator_t *enumerator;
mp = vl_msg_api_alloc (sizeof (*mp));
clib_memset (mp, 0, sizeof (*mp));
@@ -591,6 +592,13 @@
vl_msg_api_free (mp);
free (out);
+ /* clean-up */
+ enumerator = entry->addrs->create_enumerator (entry->addrs);
+ while (enumerator->enumerate (enumerator, &host))
+ {
+ host->destroy (host);
+ }
+ enumerator->destroy (enumerator);
entry->addrs->destroy (entry->addrs);
entry->addrs =
linked_list_create_from_enumerator (addrs->create_enumerator (addrs));