diff mbox

[OpenWrt-Devel,3/4] swconfig: swlib.c: free portmaps in swlib_free()

Message ID 1434642649-20330-3-git-send-email-ardeleanalex@gmail.com
State Accepted
Headers show

Commit Message

Alexandru Ardelean June 18, 2015, 3:50 p.m. UTC
From: Alexandru Ardelean <aa@ocedo.com>

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
---
 package/network/config/swconfig/src/swlib.c | 13 +++++++++++++
 package/network/config/swconfig/src/swlib.h |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/package/network/config/swconfig/src/swlib.c b/package/network/config/swconfig/src/swlib.c
index f74c093..1e0a7db 100644
--- a/package/network/config/swconfig/src/swlib.c
+++ b/package/network/config/swconfig/src/swlib.c
@@ -755,12 +755,25 @@  swlib_free_attributes(struct switch_attr **head)
 	*head = NULL;
 }
 
+static void
+swlib_free_port_map(struct switch_dev *dev)
+{
+	int i;
+	if (!dev || !dev->maps)
+		return;
+
+	for (i=0; i < dev->ports; i++)
+		free(dev->maps[i].segment);
+	free(dev->maps);
+}
+
 void
 swlib_free(struct switch_dev *dev)
 {
 	swlib_free_attributes(&dev->ops);
 	swlib_free_attributes(&dev->port_ops);
 	swlib_free_attributes(&dev->vlan_ops);
+	swlib_free_port_map(dev);
 	free(dev->name);
 	free(dev->alias);
 	free(dev);
diff --git a/package/network/config/swconfig/src/swlib.h b/package/network/config/swconfig/src/swlib.h
index 28bdd7f..2b42c14 100644
--- a/package/network/config/swconfig/src/swlib.h
+++ b/package/network/config/swconfig/src/swlib.h
@@ -158,7 +158,7 @@  struct switch_port {
 
 struct switch_portmap {
 	unsigned int virt;
-	const char *segment;
+	char *segment;
 };
 
 /**