mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-08 05:48:02 +02:00
spa-json: add _new_from_stringn() API
This commit is contained in:
parent
17a257ddbe
commit
e9be326954
2 changed files with 19 additions and 1 deletions
|
|
@ -170,11 +170,26 @@ wp_spa_json_new (const gchar *data, size_t size)
|
|||
*/
|
||||
WpSpaJson *
|
||||
wp_spa_json_new_from_string (const gchar *json_str)
|
||||
{
|
||||
return wp_spa_json_new_from_stringn(json_str, strlen (json_str));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new WpSpaJson from a JSON string with specific length.
|
||||
*
|
||||
* \ingroup wpspajson
|
||||
* \param json_str a JSON string
|
||||
* \param len the specific length of the string
|
||||
* \returns a new WpSpaJson that references the data in \a json_str. \a json_str
|
||||
* is not copied, so it needs to stay alive.
|
||||
*/
|
||||
WpSpaJson *
|
||||
wp_spa_json_new_from_stringn (const gchar *json_str, size_t len)
|
||||
{
|
||||
WpSpaJson *self = g_slice_new0 (WpSpaJson);
|
||||
g_ref_count_init (&self->ref);
|
||||
self->flags = FLAG_NO_OWNERSHIP;
|
||||
spa_json_init (&self->json_data, json_str, strlen (json_str));
|
||||
spa_json_init (&self->json_data, json_str, len);
|
||||
self->builder = NULL;
|
||||
self->data = (gchar *)self->json_data.cur;
|
||||
self->size = self->json_data.end - self->json_data.cur;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ void wp_spa_json_unref (WpSpaJson *self);
|
|||
WP_API
|
||||
WpSpaJson * wp_spa_json_new_from_string (const gchar *json_str);
|
||||
|
||||
WP_API
|
||||
WpSpaJson * wp_spa_json_new_from_stringn (const gchar *json_str, size_t len);
|
||||
|
||||
WP_API
|
||||
WpSpaJson * wp_spa_json_new_wrap (struct spa_json *json);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue