properties: clear SPA_DICT_FLAG_SORTED when adding/removing items

This allows calling spa_dict_qsort() externally on the dict,
ensuring that lookups will not break when items are added or removed.
This commit is contained in:
George Kiagiadakis 2021-03-26 18:20:00 +02:00 committed by Wim Taymans
parent 51b0248d09
commit 511cb28e17

View file

@ -396,6 +396,7 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v
if (value == NULL) if (value == NULL)
return 0; return 0;
add_func(properties, strdup(key), copy ? strdup(value) : value); add_func(properties, strdup(key), copy ? strdup(value) : value);
SPA_FLAG_CLEAR(properties->dict.flags, SPA_DICT_FLAG_SORTED);
} else { } else {
struct spa_dict_item *item = struct spa_dict_item *item =
pw_array_get_unchecked(&impl->items, index, struct spa_dict_item); pw_array_get_unchecked(&impl->items, index, struct spa_dict_item);
@ -412,6 +413,7 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v
item->value = last->value; item->value = last->value;
impl->items.size -= sizeof(struct spa_dict_item); impl->items.size -= sizeof(struct spa_dict_item);
properties->dict.n_items--; properties->dict.n_items--;
SPA_FLAG_CLEAR(properties->dict.flags, SPA_DICT_FLAG_SORTED);
} else { } else {
free((char *) item->value); free((char *) item->value);
item->value = copy ? strdup(value) : value; item->value = copy ? strdup(value) : value;