summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--strmap.c6
-rw-r--r--strmap.h6
2 files changed, 12 insertions, 0 deletions
diff --git a/strmap.c b/strmap.c
index 829f1bc095..c410c5241a 100644
--- a/strmap.c
+++ b/strmap.c
@@ -64,6 +64,12 @@ void strmap_clear(struct strmap *map, int free_values)
hashmap_clear(&map->map);
}
+void strmap_partial_clear(struct strmap *map, int free_values)
+{
+ strmap_free_entries_(map, free_values);
+ hashmap_partial_clear(&map->map);
+}
+
void *strmap_put(struct strmap *map, const char *str, void *data)
{
struct strmap_entry *entry = find_strmap_entry(map, str);
diff --git a/strmap.h b/strmap.h
index f74bc582e4..c14fcee148 100644
--- a/strmap.h
+++ b/strmap.h
@@ -43,6 +43,12 @@ void strmap_init_with_options(struct strmap *map,
void strmap_clear(struct strmap *map, int free_values);
/*
+ * Similar to strmap_clear() but leaves map->map->table allocated and
+ * pre-sized so that subsequent uses won't need as many rehashings.
+ */
+void strmap_partial_clear(struct strmap *map, int free_values);
+
+/*
* Insert "str" into the map, pointing to "data".
*
* If an entry for "str" already exists, its data pointer is overwritten, and