diff options
author | Ben Pfaff <blp@nicira.com> | 2012-06-27 11:06:10 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-07-18 10:30:50 -0700 |
commit | 51c82a49d58daebe289e045fe44009d59b1f9236 (patch) | |
tree | 23c207f6a8f7a33e4fd1e97374057423b729564e /lib/smap.c | |
parent | cccc13569249376eb2e1a364e07dfc33a745d791 (diff) |
smap: New function smap_steal().
An upcoming commit will add a caller.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/smap.c')
-rw-r--r-- | lib/smap.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -125,6 +125,18 @@ 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) +{ + char *key = node->key; + + hmap_remove(&smap->map, &node->node); + free(node); + return key; +} + /* Removes all key-value pairs from 'smap'. */ void smap_clear(struct smap *smap) |