X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Ftable.c;h=7ba47eb012a4c8a194b29fb5c89d7c389780fdf0;hb=5c9a0b820c1ff5b20f572198cda241d5cd557320;hp=96d3101f6a6a5dee5d01db644b7234f7d4755b08;hpb=629cd2f17fedf8d922f61ffd13365d1f4f9b34fe;p=openvswitch diff --git a/ovsdb/table.c b/ovsdb/table.c index 96d3101f..7ba47eb0 100644 --- a/ovsdb/table.c +++ b/ovsdb/table.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. @@ -61,6 +61,26 @@ ovsdb_table_schema_create(const char *name, const char *comment, bool mutable) return ts; } +struct ovsdb_table_schema * +ovsdb_table_schema_clone(const struct ovsdb_table_schema *old) +{ + struct ovsdb_table_schema *new; + struct shash_node *node; + + new = ovsdb_table_schema_create(old->name, old->comment, old->mutable); + SHASH_FOR_EACH (node, &old->columns) { + const struct ovsdb_column *column = node->data; + + if (column->name[0] == '_') { + /* Added automatically by ovsdb_table_schema_create(). */ + continue; + } + + add_column(new, ovsdb_column_clone(column)); + } + return new; +} + void ovsdb_table_schema_destroy(struct ovsdb_table_schema *ts) { @@ -144,7 +164,7 @@ ovsdb_table_schema_to_json(const struct ovsdb_table_schema *ts) columns = json_object_create(); SHASH_FOR_EACH (node, &ts->columns) { - struct ovsdb_column *column = node->data; + const struct ovsdb_column *column = node->data; if (node->name[0] != '_') { json_object_put(columns, column->name, ovsdb_column_to_json(column));