aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-14 22:17:27 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-14 22:17:27 +0200
commit0058c1f457a954fbdfc63f458fa00c3c5a700f69 (patch)
treef445e25d47a761910751e88ce5a579c7d9e1fa1d
parentfb502903411401200ebf77c0ab0b559f83db7a09 (diff)
downloadliberty-0058c1f457a954fbdfc63f458fa00c3c5a700f69.tar.gz
liberty-0058c1f457a954fbdfc63f458fa00c3c5a700f69.tar.xz
liberty-0058c1f457a954fbdfc63f458fa00c3c5a700f69.zip
Add str_map_steal()
-rw-r--r--liberty.c14
1 files changed, 14 insertions, 0 deletions
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.