An upcoming commit will add a caller. Signed-off-by: Ben Pfaff <b...@nicira.com> --- lib/smap.c | 12 ++++++++++++ lib/smap.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/lib/smap.c b/lib/smap.c index e612ac7..ff78598 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) diff --git a/lib/smap.h b/lib/smap.h index 8510a37..13eec1c 100644 --- a/lib/smap.h +++ b/lib/smap.h @@ -48,7 +48,8 @@ void smap_add_format(struct smap *, const char *key, const char *, ...) void smap_replace(struct smap *, const char *, const char *); void smap_remove(struct smap *, const char *); -void smap_remove_node(struct smap *smap, struct smap_node *); +void smap_remove_node(struct smap *, struct smap_node *); +char *smap_steal(struct smap *, struct smap_node *); void smap_clear(struct smap *); const char *smap_get(const struct smap *, const char *); -- 1.7.2.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev