GLib.Variant.new_from_data
Description: Reference for GLib.Variant.new_from_data

### Function

# GLib Variantnew_from_data

since: 2.24

#### Declaration [src]

    GVariant*
    g_variant_new_from_data (
      const GVariantType* type,
      gconstpointer data,
      gsize size,
      gboolean trusted,
      GDestroyNotify notify,
      gpointer user_data
    )

#### Description [src]

Creates a new `GVariant` instance from serialized data.

`type` is the type of `GVariant` instance that will be constructed. The interpretation of `data` depends on knowing the type.

`data` is not modified by this function and must remain valid with an unchanging value until such a time as `notify` is called with `user_data`. If the contents of `data` change before that time then the result is undefined.

If `data` is trusted to be serialized data in normal form then `trusted` should be `TRUE`. This applies to serialized data created within this process or read from a trusted location on the disk (such as a file installed in /usr/lib alongside your application). You should set trusted to `FALSE` if `data` is read from the network, a file in the user’s home directory, etc.

If `data` was not stored in this machine’s native endianness, any multi-byte numeric values in the returned variant will also be in non-native endianness. `g_variant_byteswap()` can be used to recover the original values.

`notify` will be called with `user_data` when `data` is no longer needed. The exact time of this call is unspecified and might even be before this function returns.

Note: `data` must be backed by memory that is aligned appropriately for the `type` being loaded. Otherwise this function will internally create a copy of the memory (since GLib 2.60) or (in older versions) fail and exit the process.

Available since: 2.24

#### Parameters

`type`

  Type: `GVariantType`

  A definite `GVariantType`.

  The data is owned by the caller of the function.

`data`

  Type: An array of `guint8`

  The serialized data.

  The length of the array is specified in the `size` argument.

`size`

  Type: `gsize`

  The size of `data`.

`trusted`

  Type: `gboolean`

  `TRUE` if `data` is definitely in normal form.

`notify`

  Type: `GDestroyNotify`

  Function to call when `data` is no longer needed.

`user_data`

  Type: `gpointer`

  Data for `notify`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

#### Return value

Type: `GVariant`

A new floating `GVariant` of type `type`.

The data is owned by the called function.