conf: use serialize_dict to write state files

Instead of our home-brew version.
This commit is contained in:
Wim Taymans 2021-06-09 18:00:47 +02:00
parent 54326abd54
commit 262e609b73

View file

@ -215,7 +215,6 @@ found:
SPA_EXPORT
int pw_conf_save_state(const char *prefix, const char *name, struct pw_properties *conf)
{
const struct spa_dict_item *it;
char path[PATH_MAX];
char *tmp_name;
int res, sfd, fd, count = 0;
@ -234,14 +233,7 @@ int pw_conf_save_state(const char *prefix, const char *name, struct pw_propertie
f = fdopen(fd, "w");
fprintf(f, "{");
spa_dict_for_each(it, &conf->dict) {
char key[1024];
if (spa_json_encode_string(key, sizeof(key)-1, it->key) >= (int)sizeof(key)-1)
continue;
fprintf(f, "%s\n %s: %s", count++ == 0 ? "" : ",", key, it->value);
}
count += pw_properties_serialize_dict(f, &conf->dict, PW_PROPERTIES_FLAG_NL);
fprintf(f, "%s}", count == 0 ? " " : "\n");
fclose(f);