X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Fcolumn.c;h=58fff1084fd9ae1b8b1bf86ea49a91d86af9f1b7;hb=90887925206f585db65ae8872f197a97543f2860;hp=73dc9c24c16015d97dc8d0b5945e45ca2335fc88;hpb=a4af00400a835eb87569ba40e21874c05e872c0f;p=openvswitch diff --git a/ovsdb/column.c b/ovsdb/column.c index 73dc9c24..58fff108 100644 --- a/ovsdb/column.c +++ b/ovsdb/column.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. @@ -31,6 +31,7 @@ ovsdb_column_create(const char *name, const char *comment, bool mutable, bool persistent, const struct ovsdb_type *type) { + /* Doesn't set the new column's 'index': the caller must do that. */ struct ovsdb_column *column; column = xzalloc(sizeof *column); @@ -38,14 +39,24 @@ ovsdb_column_create(const char *name, const char *comment, column->comment = comment ? xstrdup(comment) : NULL; column->mutable = mutable; column->persistent = persistent; - column->type = *type; + ovsdb_type_clone(&column->type, type); return column; } +struct ovsdb_column * +ovsdb_column_clone(const struct ovsdb_column *old) +{ + /* Doesn't copy the column's 'index': the caller must do that. */ + return ovsdb_column_create(old->name, old->comment, + old->mutable, old->persistent, + &old->type); +} + void ovsdb_column_destroy(struct ovsdb_column *column) { + ovsdb_type_destroy(&column->type); free(column->name); free(column->comment); free(column); @@ -85,6 +96,9 @@ ovsdb_column_from_json(const struct json *json, const char *name, comment ? json_string(comment) : NULL, mutable ? json_boolean(mutable) : true, persistent, &type); + + ovsdb_type_destroy(&type); + return NULL; } @@ -152,7 +166,7 @@ ovsdb_column_set_from_json(const struct json *json, /* XXX this is O(n**2) */ for (i = 0; i < json->u.array.n; i++) { - struct ovsdb_column *column; + const struct ovsdb_column *column; const char *s; if (json->u.array.elems[i]->type != JSON_STRING) {