mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-04-26 19:40:42 +02:00
spa-json: wrap the data instead of the spa_json* in _parser_get_json()
This allows the returned WpSpaJson object to be kept around after the parser has advanced to the next token. The behaviour of the _new_wrap() function is to wrap the underlying spa_json* and it breaks as soon as the parser advances.
This commit is contained in:
parent
ccdca1ffb4
commit
64c233f3f4
1 changed files with 6 additions and 1 deletions
|
|
@ -1524,6 +1524,10 @@ wp_spa_json_parser_get_string (WpSpaJsonParser *self)
|
|||
/*!
|
||||
* \brief Gets the spa json value from a spa json parser object
|
||||
*
|
||||
* \note the returned spa json object references the original data instead
|
||||
* of copying it, therefore the original data must be valid for the entire
|
||||
* life-cycle of the returned object
|
||||
*
|
||||
* \ingroup wpspajson
|
||||
* \param self the spa json parser object
|
||||
* \returns (transfer full): The spa json value or NULL if it could not be
|
||||
|
|
@ -1533,7 +1537,8 @@ WpSpaJson *
|
|||
wp_spa_json_parser_get_json (WpSpaJsonParser *self)
|
||||
{
|
||||
return wp_spa_json_parser_advance (self) ?
|
||||
wp_spa_json_new_wrap (&self->curr) : NULL;
|
||||
wp_spa_json_new_wrap_stringn (self->curr.cur,
|
||||
self->curr.end - self->curr.cur) : NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue