dpif-netlink: add GENEVE creation support
[cascardo/ovs.git] / ovsdb / row.c
index 457869b..572c103 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 #include "row.h"
 
-#include <assert.h>
 #include <stddef.h>
 
-#include "dynamic-string.h"
+#include "openvswitch/dynamic-string.h"
 #include "json.h"
 #include "ovsdb-error.h"
 #include "shash.h"
@@ -36,10 +35,10 @@ allocate_row(const struct ovsdb_table *table)
                        + sizeof(struct ovsdb_datum) * n_fields
                        + sizeof(struct hmap_node) * n_indexes);
     struct ovsdb_row *row = xmalloc(row_size);
-    row->table = (struct ovsdb_table *) table;
+    row->table = CONST_CAST(struct ovsdb_table *, table);
     row->txn_row = NULL;
-    list_init(&row->src_refs);
-    list_init(&row->dst_refs);
+    ovs_list_init(&row->src_refs);
+    ovs_list_init(&row->dst_refs);
     row->n_refs = 0;
     return row;
 }
@@ -86,14 +85,14 @@ ovsdb_row_destroy(struct ovsdb_row *row)
         const struct shash_node *node;
 
         LIST_FOR_EACH_SAFE (weak, next, dst_node, &row->dst_refs) {
-            list_remove(&weak->src_node);
-            list_remove(&weak->dst_node);
+            ovs_list_remove(&weak->src_node);
+            ovs_list_remove(&weak->dst_node);
             free(weak);
         }
 
         LIST_FOR_EACH_SAFE (weak, next, src_node, &row->src_refs) {
-            list_remove(&weak->src_node);
-            list_remove(&weak->dst_node);
+            ovs_list_remove(&weak->src_node);
+            ovs_list_remove(&weak->dst_node);
             free(weak);
         }
 
@@ -342,12 +341,11 @@ ovsdb_row_hash_init(struct ovsdb_row_hash *rh,
 void
 ovsdb_row_hash_destroy(struct ovsdb_row_hash *rh, bool destroy_rows)
 {
-    struct ovsdb_row_hash_node *node, *next;
+    struct ovsdb_row_hash_node *node;
 
-    HMAP_FOR_EACH_SAFE (node, next, hmap_node, &rh->rows) {
-        hmap_remove(&rh->rows, &node->hmap_node);
+    HMAP_FOR_EACH_POP (node, hmap_node, &rh->rows) {
         if (destroy_rows) {
-            ovsdb_row_destroy((struct ovsdb_row *) node->row);
+            ovsdb_row_destroy(CONST_CAST(struct ovsdb_row *, node->row));
         }
         free(node);
     }
@@ -376,7 +374,7 @@ ovsdb_row_hash_contains_all(const struct ovsdb_row_hash *a,
 {
     struct ovsdb_row_hash_node *node;
 
-    assert(ovsdb_column_set_equals(&a->columns, &b->columns));
+    ovs_assert(ovsdb_column_set_equals(&a->columns, &b->columns));
     HMAP_FOR_EACH (node, hmap_node, &b->rows) {
         if (!ovsdb_row_hash_contains__(a, node->row, node->hmap_node.hash)) {
             return false;