From 80011403d0c1dfb0961b6eb41b6e50fa1f994031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sat, 12 Jun 2021 15:49:22 +0200 Subject: [PATCH] pipewire: properties: clear sorted flag in add/remove Move the clearing of the SPA_DICT_FLAG_SORTED into `add_item()` and `remove_item()`. --- src/pipewire/properties.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index 9f894356a..a513253bc 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -56,6 +56,9 @@ static int add_item(struct pw_properties *this, char *key, char *value) this->dict.items = impl->items.data; this->dict.n_items++; + + SPA_FLAG_CLEAR(this->dict.flags, SPA_DICT_FLAG_SORTED); + return 0; } @@ -66,8 +69,11 @@ static void remove_item(struct pw_properties *this, struct spa_dict_item *item) item->key = last->key; item->value = last->value; + impl->items.size -= sizeof(*item); this->dict.n_items--; + + SPA_FLAG_CLEAR(this->dict.flags, SPA_DICT_FLAG_SORTED); } static void clear_item(struct spa_dict_item *item) @@ -406,7 +412,6 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v if (value == NULL) return 0; add_item(properties, strdup(key), copy ? strdup(value) : value); - SPA_FLAG_CLEAR(properties->dict.flags, SPA_DICT_FLAG_SORTED); } else { if (value && spa_streq(item->value, value)) goto exit_noupdate; @@ -414,7 +419,6 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v if (value == NULL) { clear_item(item); remove_item(properties, item); - SPA_FLAG_CLEAR(properties->dict.flags, SPA_DICT_FLAG_SORTED); } else { free((char *) item->value); item->value = copy ? strdup(value) : value;