From: Ben Pfaff Date: Thu, 10 Jun 2010 21:40:13 +0000 (-0700) Subject: Use shash_destroy_free_data() to simplify a few scattered pieces of code. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=506051fcb52f8d679bb6d00761fa90a4afa79208;p=openvswitch Use shash_destroy_free_data() to simplify a few scattered pieces of code. --- diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index ee98c80d..39d10ede 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -1513,14 +1513,7 @@ void ovsdb_symbol_table_destroy(struct ovsdb_symbol_table *symtab) { if (symtab) { - struct shash_node *node, *next; - - SHASH_FOR_EACH_SAFE (node, next, &symtab->sh) { - struct ovsdb_symbol *symbol = node->data; - free(symbol); - shash_delete(&symtab->sh, node); - } - shash_destroy(&symtab->sh); + shash_destroy_free_data(&symtab->sh); free(symtab); } } diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index aea317ca..c16767d7 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -624,17 +624,8 @@ free_info(struct vsctl_info *info) } shash_destroy(&info->bridges); - SHASH_FOR_EACH (node, &info->ports) { - struct vsctl_port *port = node->data; - free(port); - } - shash_destroy(&info->ports); - - SHASH_FOR_EACH (node, &info->ifaces) { - struct vsctl_iface *iface = node->data; - free(iface); - } - shash_destroy(&info->ifaces); + shash_destroy_free_data(&info->ports); + shash_destroy_free_data(&info->ifaces); } static void diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 47f269f9..a295fc01 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -362,7 +362,6 @@ static int set_up_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface, bool create) { - struct shash_node *node; struct shash options; int error = 0; size_t i; @@ -410,11 +409,7 @@ set_up_iface(const struct ovsrec_interface *iface_cfg, struct iface *iface, error = EINVAL; } } - - SHASH_FOR_EACH (node, &options) { - free(node->data); - } - shash_destroy(&options); + shash_destroy_free_data(&options); return error; }