From 506051fcb52f8d679bb6d00761fa90a4afa79208 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@nicira.com>
Date: Thu, 10 Jun 2010 14:40:13 -0700
Subject: [PATCH] Use shash_destroy_free_data() to simplify a few scattered
 pieces of code.

---
 lib/ovsdb-data.c      |  9 +--------
 utilities/ovs-vsctl.c | 13 ++-----------
 vswitchd/bridge.c     |  7 +------
 3 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c
index ee98c80d3..39d10ede3 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 aea317cad..c16767d7e 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 47f269f9e..a295fc014 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;
 }
-- 
2.47.0