X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsmap.c;h=ff785981226425d7a42dd34e44e44d2ea617a295;hb=51c82a49d58daebe289e045fe44009d59b1f9236;hp=e612ac7bad7749bf1a8212cf98af2e91ad177704;hpb=cccc13569249376eb2e1a364e07dfc33a745d791;p=openvswitch 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)