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 ee98c80d3e6f3926e7a8c3b032fc8cb334d3b4df..39d10ede36eadd86b6a00190162e8e59a0b0228e 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 aea317cadb54e4fdf48a1f2c9dda1192d801b876..c16767d7ee01d4f7315edacf45b4d1740f3d43e0 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 47f269f9e07a180f44989de7e083dfb15ceb43ba..a295fc014dbef9a580a35509d5ec7061449f185d 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;
 }