* that size and serialises the instance into the buffer. The
* 'children' array is then released and the instance is set to
* serialised form based on the contents of the buffer.
- *
- * The current thread must hold the lock on @value.
*/
static void
g_variant_ensure_serialised (GVariant *value)
{
- g_assert (value->state & STATE_LOCKED);
-
- if (~value->state & STATE_SERIALISED)
+ if (g_variant_lock_in_tree_form (value))
{
GBytes *bytes;
gpointer data;
value->contents.serialised.data = g_bytes_get_data (bytes, NULL);
value->contents.serialised.bytes = bytes;
value->state |= STATE_SERIALISED;
+
+ g_variant_unlock (value);
}
}
gconstpointer
g_variant_get_data (GVariant *value)
{
- g_variant_lock (value);
g_variant_ensure_serialised (value);
- g_variant_unlock (value);
return value->contents.serialised.data;
}
gsize bytes_size;
gsize size;
- g_variant_lock (value);
g_variant_ensure_serialised (value);
- g_variant_unlock (value);
bytes_data = g_bytes_get_data (value->contents.serialised.bytes, &bytes_size);
data = value->contents.serialised.data;