From 0058c1f457a954fbdfc63f458fa00c3c5a700f69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Tue, 14 Jul 2015 22:17:27 +0200
Subject: [PATCH] Add str_map_steal()
---
liberty.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/liberty.c b/liberty.c
index c3c5cf9..ad1efba 100644
--- a/liberty.c
+++ b/liberty.c
@@ -872,6 +872,20 @@ str_map_find (struct str_map *self, const char *key)
return str_map_find_real (self, tmp);
}
+static void *
+str_map_steal (struct str_map *self, const char *key)
+{
+ void *value = str_map_find (self, key);
+ if (value)
+ {
+ str_map_free_fn free_saved = self->free;
+ self->free = NULL;
+ str_map_set (self, key, NULL);
+ self->free = free_saved;
+ }
+ return value;
+}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// This iterator is intended for accessing and eventually adding links.