diff options
author | Ben Pfaff <blp@nicira.com> | 2012-07-18 10:51:02 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-07-18 10:51:02 -0700 |
commit | 57c8677b511908b3120df3cbf44244423cfefc34 (patch) | |
tree | 1770ef8c0a4335de9244315e94f59c20b8b3c855 /lib/smap.c | |
parent | 51c82a49d58daebe289e045fe44009d59b1f9236 (diff) |
system-stats: Use "smap" instead of "shash".
"smap" is now the appropriate data structure for a string-to-string map.
Also changes ovsdb_datum_from_shash() into ovsdb_datum_from_smap() since
system-stats related code was the only client.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/smap.c')
-rw-r--r-- | lib/smap.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -125,16 +125,29 @@ smap_remove_node(struct smap *smap, struct smap_node *node) free(node); } -/* Deletes 'node' from 'sh'. Neither the node's key nor its value is freed; - * instead, ownership is transferred to the caller. Returns the node's key. */ -char * -smap_steal(struct smap *smap, struct smap_node *node) +/* Deletes 'node' from 'smap'. + * + * If 'keyp' is nonnull, stores the node's key in '*keyp' and transfers + * ownership to the caller. Otherwise, frees the node's key. Similarly for + * 'valuep' and the node's value. */ +void +smap_steal(struct smap *smap, struct smap_node *node, + char **keyp, char **valuep) { - char *key = node->key; + if (keyp) { + *keyp = node->key; + } else { + free(node->key); + } + + if (valuep) { + *valuep = node->value; + } else { + free(node->value); + } hmap_remove(&smap->map, &node->node); free(node); - return key; } /* Removes all key-value pairs from 'smap'. */ |