X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fstring-map.c;h=e3a81b4fe1457a030154fb3cb05cfc59cd3bb059;hp=71eac6349a896ef49fe1cbfea3378a308951e1a4;hb=HEAD;hpb=763445beaec906440fbdd497755718ef860b88e4 diff --git a/lib/string-map.c b/lib/string-map.c index 71eac634..99bc2ea2 100644 --- a/lib/string-map.c +++ b/lib/string-map.c @@ -86,10 +86,14 @@ _notmuch_string_map_append (notmuch_string_map_t *map, static int cmppair (const void *pa, const void *pb) { + int cmp = 0; notmuch_string_pair_t *a = (notmuch_string_pair_t *) pa; notmuch_string_pair_t *b = (notmuch_string_pair_t *) pb; - return strcmp (a->key, b->key); + cmp = strcmp (a->key, b->key); + if (cmp == 0) + cmp = strcmp (a->value, b->value); + return cmp; } static void @@ -154,10 +158,10 @@ _notmuch_string_map_set (notmuch_string_map_t *map, _notmuch_string_map_sort (map); pair = bsearch_first (map->pairs, map->length, key, true); if (! pair) - _notmuch_string_map_append (map, key, val); + _notmuch_string_map_append (map, key, val); else { - talloc_free (pair->value); - pair->value = talloc_strdup (map->pairs, val); + talloc_free (pair->value); + pair->value = talloc_strdup (map->pairs, val); } }