Use shash_destroy_free_data() to simplify a few scattered pieces of code.
authorBen Pfaff <blp@nicira.com>
Thu, 10 Jun 2010 21:40:13 +0000 (14:40 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 23 Jun 2010 19:43:02 +0000 (12:43 -0700)
lib/ovsdb-data.c
utilities/ovs-vsctl.c
vswitchd/bridge.c

index ee98c80..39d10ed 100644 (file)
@@ -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);
     }
 }
index aea317c..c16767d 100644 (file)
@@ -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
index 47f269f..a295fc0 100644 (file)
@@ -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;
 }