### Function

# Gio Resource new_from_data

since: 2.32

#### Declaration [src]

    GResource*
    g_resource_new_from_data (
      GBytes* data,
      GError** error
    )

#### Description [src]

Creates a GResource from a reference to the binary resource bundle. This will keep a reference to `data` while the resource lives, so the data should not be modified or freed.

If you want to use this resource in the global resource namespace you need to register it with g_resources_register().

Note: `data` must be backed by memory that is at least pointer aligned. Otherwise this function will internally create a copy of the memory since GLib 2.56, or in older versions fail and exit the process.

If `data` is empty or corrupt, `G_RESOURCE_ERROR_INTERNAL` will be returned.

Available since: 2.32

#### Parameters

`data`

  Type: `GBytes`

  A `GBytes`.

  The data is owned by the caller of the function.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `GResource`

A new `GResource`, or `NULL` on error.

The caller of the function takes ownership of the data, and is responsible for freeing it.