X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fovsdb-data.c;h=df445d775c12d5eb91302286ef4506354b123189;hb=ef5e2fe54d0a54a66f9c696be532ced8db9110fc;hp=46298cb47694c2ae662b738b3df311c59112b998;hpb=58fda1dab104041fc693032475ec4662c1a52849;p=openvswitch diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c index 46298cb4..df445d77 100644 --- a/lib/ovsdb-data.c +++ b/lib/ovsdb-data.c @@ -219,13 +219,13 @@ ovsdb_atom_parse_uuid(struct uuid *uuid, const struct json *json, error1 = unwrap_json(json, "named-uuid", JSON_STRING, &value); if (!error1) { const char *name = json_string(value); - const struct uuid *named_uuid; + const struct ovsdb_symbol *symbol; ovsdb_error_destroy(error0); - named_uuid = ovsdb_symbol_table_get(symtab, name); - if (named_uuid) { - *uuid = *named_uuid; + symbol = ovsdb_symbol_table_get(symtab, name); + if (symbol) { + *uuid = symbol->uuid; return NULL; } else { return ovsdb_syntax_error(json, NULL, @@ -728,7 +728,8 @@ ovsdb_symbol_table_destroy(struct ovsdb_symbol_table *symtab) struct shash_node *node, *next; SHASH_FOR_EACH_SAFE (node, next, &symtab->sh) { - free(node->data); + struct ovsdb_symbol *symbol = node->data; + free(symbol); shash_delete(&symtab->sh, node); } shash_destroy(&symtab->sh); @@ -736,7 +737,7 @@ ovsdb_symbol_table_destroy(struct ovsdb_symbol_table *symtab) } } -const struct uuid * +struct ovsdb_symbol * ovsdb_symbol_table_get(const struct ovsdb_symbol_table *symtab, const char *name) { @@ -745,12 +746,13 @@ ovsdb_symbol_table_get(const struct ovsdb_symbol_table *symtab, void ovsdb_symbol_table_put(struct ovsdb_symbol_table *symtab, const char *name, - const struct uuid *uuid) + const struct uuid *uuid, bool used) { - struct uuid *entry = shash_find_data(&symtab->sh, name); - if (!entry) { - shash_add(&symtab->sh, name, xmemdup(uuid, sizeof *uuid)); - } else { - *entry = *uuid; - } + struct ovsdb_symbol *symbol; + + assert(!ovsdb_symbol_table_get(symtab, name)); + symbol = xmalloc(sizeof *symbol); + symbol->uuid = *uuid; + symbol->used = used; + shash_add(&symtab->sh, name, symbol); }