/** * g_variant_new_from_bytes: * @type: a #GVariantType * @bytes: a #GBytes * @trusted: if the contents of @bytes are trusted * * Constructs a new serialised-mode #GVariant instance. This is the * inner interface for creation of new serialised values that gets * called from various functions in gvariant.c. * * A reference is taken on @bytes. * * Returns: a new #GVariant with a floating reference * * Since: 2.36 */ GVariant * g_variant_new_from_bytes (const GVariantType *type, GBytes *bytes, gboolean trusted) { GVariant *value; guint alignment; gsize size; value = g_variant_alloc (type, TRUE, trusted); value->contents.serialised.bytes = g_bytes_ref (bytes); g_variant_type_info_query (value->type_info, &alignment, &size); if (size && g_bytes_get_size (bytes) != size) { /* Creating a fixed-sized GVariant with a bytes of the wrong * size. * * We should do the equivalent of pulling a fixed-sized child out * of a brozen container (ie: data is NULL size is equal to the correct * fixed size). */ value->contents.serialised.data = NULL; value->size = size; } else { value->contents.serialised.data = g_bytes_get_data (bytes, &value->size); } return value; }
/* < internal > * g_variant_new_from_children: * @type: a #GVariantType * @children: an array of #GVariant pointers. Consumed. * @n_children: the length of @children * @trusted: %TRUE if every child in @children in trusted * * Constructs a new tree-mode #GVariant instance. This is the inner * interface for creation of new serialised values that gets called from * various functions in gvariant.c. * * @children is consumed by this function. g_free() will be called on * it some time later. * * Returns: a new #GVariant with a floating reference */ GVariant * g_variant_new_from_children (const GVariantType *type, GVariant **children, gsize n_children, gboolean trusted) { GVariant *value; value = g_variant_alloc (type, FALSE, trusted); value->contents.tree.children = children; value->contents.tree.n_children = n_children; return value; }
/* < internal > * g_variant_new_from_children: * @type: a #GVariantType * @children: an array of #GVariant pointers. Consumed. * @n_children: the length of @children * @trusted: %TRUE if every child in @children in trusted * * Constructs a new tree-mode #GVariant instance. This is the inner * interface for creation of new serialised values that gets called from * various functions in gvariant.c. * * @children is consumed by this function. g_free() will be called on * it some time later. * * Returns: a new #GVariant with a floating reference */ GVariant * g_variant_new_from_children (const GVariantType *type, GVariant **children, gsize n_children, gboolean trusted) { GVariant *value; value = g_variant_alloc (type, FALSE, trusted); #ifdef GSTREAMER_LITE if (value == NULL) { return NULL; } #endif // GSTREAMER_LITE value->contents.tree.children = children; value->contents.tree.n_children = n_children; return value; }