From: John Crispin Date: Tue, 7 Jul 2015 13:46:05 +0000 (+0000) Subject: swconfig: swlib.c: free portmaps in swlib_free() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=294907aa3ab96d8fbee05082ef4db3f886eb0321;p=openwrt%2Fstaging%2Frmilecki.git swconfig: swlib.c: free portmaps in swlib_free() Signed-off-by: Alexandru Ardelean SVN-Revision: 46231 --- diff --git a/package/network/config/swconfig/src/swlib.c b/package/network/config/swconfig/src/swlib.c index f74c093ef4e..d7e570e05d1 100644 --- a/package/network/config/swconfig/src/swlib.c +++ b/package/network/config/swconfig/src/swlib.c @@ -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); diff --git a/package/network/config/swconfig/src/swlib.h b/package/network/config/swconfig/src/swlib.h index 28bdd7f7cbe..2b42c147608 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; }; /**