mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
spa: add spa_json_object_next
This gets the next key and value from an object. This function is better because it will skip key/value pairs that don't fit in the array to hold the key. The previous code patter would stop parsing the object as soon as a key larger than the available space was found.
This commit is contained in:
parent
cd81b5f39a
commit
ce390d5b22
24 changed files with 171 additions and 269 deletions
|
|
@ -276,17 +276,14 @@ static int parse_socket_args(struct impl *impl, const char *str)
|
|||
{
|
||||
struct spa_json it[1];
|
||||
char socket[PATH_MAX];
|
||||
const char *val;
|
||||
int len;
|
||||
|
||||
if (spa_json_begin_object(&it[0], str, strlen(str)) <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
while (spa_json_get_string(&it[0], socket, sizeof(socket)) > 0) {
|
||||
while ((len = spa_json_object_next(&it[0], socket, sizeof(socket), &val)) > 0) {
|
||||
char value[256];
|
||||
const char *val;
|
||||
int len;
|
||||
|
||||
if ((len = spa_json_next(&it[0], &val)) <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (spa_json_parse_stringn(val, len, value, sizeof(value)) <= 0)
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue