+void
+_notmuch_string_map_set (notmuch_string_map_t *map,
+ const char *key,
+ const char *val)
+{
+ notmuch_string_pair_t *pair;
+
+ /* this means that calling string_map_set invalidates iterators */
+ _notmuch_string_map_sort (map);
+ pair = bsearch_first (map->pairs, map->length, key, true);
+ if (! pair)
+ _notmuch_string_map_append (map, key, val);
+ else {
+ talloc_free (pair->value);
+ pair->value = talloc_strdup (map->pairs, val);
+ }
+}
+