swconfig: swlib.c: free portmaps in swlib_free()
authorJohn Crispin <john@openwrt.org>
Tue, 7 Jul 2015 13:46:05 +0000 (13:46 +0000)
committerJohn Crispin <john@openwrt.org>
Tue, 7 Jul 2015 13:46:05 +0000 (13:46 +0000)
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
SVN-Revision: 46231

package/network/config/swconfig/src/swlib.c
package/network/config/swconfig/src/swlib.h

index f74c093ef4ea4490f69a5d3f8f73ff09a90b7bdb..d7e570e05d1d427b408834a59e4e3ccf00ffccc8 100644 (file)
@@ -755,12 +755,26 @@ 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);
index 28bdd7f7cbea22c1070c98cc72c93fe04bc6ae5f..2b42c1476088ab03148b0585352cce765e662d20 100644 (file)
@@ -158,7 +158,7 @@ struct switch_port {
 
 struct switch_portmap {
        unsigned int virt;
-       const char *segment;
+       char *segment;
 };
 
 /**