aboutsummaryrefslogtreecommitdiff
path: root/lib/smap.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-06-27 11:06:10 -0700
committerBen Pfaff <blp@nicira.com>2012-07-18 10:30:50 -0700
commit51c82a49d58daebe289e045fe44009d59b1f9236 (patch)
tree23c207f6a8f7a33e4fd1e97374057423b729564e /lib/smap.c
parentcccc13569249376eb2e1a364e07dfc33a745d791 (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.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/smap.c b/lib/smap.c
index e612ac7b..ff785981 100644
--- a/lib/smap.c
+++ b/lib/smap.c
@@ -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)