projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ovs-pki: Fix handling of relative log file name on --log option.
[openvswitch]
/
ovsdb
/
column.c
diff --git
a/ovsdb/column.c
b/ovsdb/column.c
index 73dc9c24c16015d97dc8d0b5945e45ca2335fc88..a22e1a237021dba1f4e242ff41a3e191f0d5869d 100644
(file)
--- 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-27,27
+27,36
@@
#include "util.h"
struct ovsdb_column *
#include "util.h"
struct ovsdb_column *
-ovsdb_column_create(const char *name,
const char *comment,
+ovsdb_column_create(const char *name,
bool mutable, bool persistent,
const struct ovsdb_type *type)
{
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);
column->name = xstrdup(name);
struct ovsdb_column *column;
column = xzalloc(sizeof *column);
column->name = xstrdup(name);
- column->comment = comment ? xstrdup(comment) : NULL;
column->mutable = mutable;
column->persistent = persistent;
column->mutable = mutable;
column->persistent = persistent;
-
column->type = *type
;
+
ovsdb_type_clone(&column->type, type)
;
return column;
}
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->mutable, old->persistent,
+ &old->type);
+}
+
void
ovsdb_column_destroy(struct ovsdb_column *column)
{
void
ovsdb_column_destroy(struct ovsdb_column *column)
{
+ ovsdb_type_destroy(&column->type);
free(column->name);
free(column->name);
- free(column->comment);
free(column);
}
free(column);
}
@@
-55,7
+64,7
@@
struct ovsdb_error *
ovsdb_column_from_json(const struct json *json, const char *name,
struct ovsdb_column **columnp)
{
ovsdb_column_from_json(const struct json *json, const char *name,
struct ovsdb_column **columnp)
{
- const struct json *
comment, *
mutable, *ephemeral, *type_json;
+ const struct json *mutable, *ephemeral, *type_json;
struct ovsdb_error *error;
struct ovsdb_type type;
struct ovsdb_parser parser;
struct ovsdb_error *error;
struct ovsdb_type type;
struct ovsdb_parser parser;
@@
-64,7
+73,6
@@
ovsdb_column_from_json(const struct json *json, const char *name,
*columnp = NULL;
ovsdb_parser_init(&parser, json, "schema for column %s", name);
*columnp = NULL;
ovsdb_parser_init(&parser, json, "schema for column %s", name);
- comment = ovsdb_parser_member(&parser, "comment", OP_STRING | OP_OPTIONAL);
mutable = ovsdb_parser_member(&parser, "mutable",
OP_TRUE | OP_FALSE | OP_OPTIONAL);
ephemeral = ovsdb_parser_member(&parser, "ephemeral",
mutable = ovsdb_parser_member(&parser, "mutable",
OP_TRUE | OP_FALSE | OP_OPTIONAL);
ephemeral = ovsdb_parser_member(&parser, "ephemeral",
@@
-82,9
+90,11
@@
ovsdb_column_from_json(const struct json *json, const char *name,
persistent = ephemeral ? !json_boolean(ephemeral) : true;
*columnp = ovsdb_column_create(name,
persistent = ephemeral ? !json_boolean(ephemeral) : true;
*columnp = ovsdb_column_create(name,
- comment ? json_string(comment) : NULL,
mutable ? json_boolean(mutable) : true,
persistent, &type);
mutable ? json_boolean(mutable) : true,
persistent, &type);
+
+ ovsdb_type_destroy(&type);
+
return NULL;
}
return NULL;
}
@@
-92,9
+102,6
@@
struct json *
ovsdb_column_to_json(const struct ovsdb_column *column)
{
struct json *json = json_object_create();
ovsdb_column_to_json(const struct ovsdb_column *column)
{
struct json *json = json_object_create();
- if (column->comment) {
- json_object_put_string(json, "comment", column->comment);
- }
if (!column->mutable) {
json_object_put(json, "mutable", json_boolean_create(false));
}
if (!column->mutable) {
json_object_put(json, "mutable", json_boolean_create(false));
}
@@
-152,7
+159,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++) {
/* 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) {
const char *s;
if (json->u.array.elems[i]->type != JSON_STRING) {