mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-15 07:00:05 -05:00
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:
parent
51b0248d09
commit
511cb28e17
1 changed files with 2 additions and 0 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue