smap: New function smap_steal().
[openvswitch] / lib / smap.c
index e612ac7bad7749bf1a8212cf98af2e91ad177704..ff785981226425d7a42dd34e44e44d2ea617a295 100644 (file)
@@ -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)