X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Frow.c;h=ba00bb9f3059140b965b00989fd49298c5898f95;hb=a56104575c4db202bfc5db3079ea969820d77867;hp=1b8194201df4b7d9d66aee126fa5ed866a135763;hpb=58fda1dab104041fc693032475ec4662c1a52849;p=openvswitch diff --git a/ovsdb/row.c b/ovsdb/row.c index 1b819420..ba00bb9f 100644 --- a/ovsdb/row.c +++ b/ovsdb/row.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009 Nicira Networks +/* Copyright (c) 2009, 2010 Nicira Networks * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,9 @@ allocate_row(const struct ovsdb_table *table) struct ovsdb_row *row = xmalloc(row_size); row->table = (struct ovsdb_table *) table; row->txn_row = NULL; + list_init(&row->src_refs); + list_init(&row->dst_refs); + row->n_refs = 0; return row; } @@ -76,8 +79,21 @@ ovsdb_row_destroy(struct ovsdb_row *row) { if (row) { const struct ovsdb_table *table = row->table; + struct ovsdb_weak_ref *weak, *next; 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); + free(weak); + } + + LIST_FOR_EACH_SAFE (weak, next, src_node, &row->src_refs) { + list_remove(&weak->src_node); + list_remove(&weak->dst_node); + free(weak); + } + SHASH_FOR_EACH (node, &table->schema->columns) { const struct ovsdb_column *column = node->data; ovsdb_datum_destroy(&row->fields[column->index], &column->type); @@ -159,7 +175,7 @@ ovsdb_row_update_columns(struct ovsdb_row *dst, struct ovsdb_error * ovsdb_row_from_json(struct ovsdb_row *row, const struct json *json, - const struct ovsdb_symbol_table *symtab, + struct ovsdb_symbol_table *symtab, struct ovsdb_column_set *included) { struct ovsdb_table_schema *schema = row->table->schema; @@ -308,8 +324,7 @@ ovsdb_row_hash_destroy(struct ovsdb_row_hash *rh, bool destroy_rows) { struct ovsdb_row_hash_node *node, *next; - HMAP_FOR_EACH_SAFE (node, next, struct ovsdb_row_hash_node, hmap_node, - &rh->rows) { + HMAP_FOR_EACH_SAFE (node, next, hmap_node, &rh->rows) { hmap_remove(&rh->rows, &node->hmap_node); if (destroy_rows) { ovsdb_row_destroy((struct ovsdb_row *) node->row); @@ -342,7 +357,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)); - HMAP_FOR_EACH (node, struct ovsdb_row_hash_node, hmap_node, &b->rows) { + HMAP_FOR_EACH (node, hmap_node, &b->rows) { if (!ovsdb_row_hash_contains__(a, node->row, node->hmap_node.hash)) { return false; } @@ -362,8 +377,7 @@ ovsdb_row_hash_contains__(const struct ovsdb_row_hash *rh, const struct ovsdb_row *row, size_t hash) { struct ovsdb_row_hash_node *node; - HMAP_FOR_EACH_WITH_HASH (node, struct ovsdb_row_hash_node, hmap_node, - hash, &rh->rows) { + HMAP_FOR_EACH_WITH_HASH (node, hmap_node, hash, &rh->rows) { if (ovsdb_row_equal_columns(row, node->row, &rh->columns)) { return true; }