### Constructor

# JavaScriptCore Value new_array_buffer

since: 2.38

#### Declaration [src]

    JSCValue*
    jsc_value_new_array_buffer (
      JSCContext* context,
      gpointer data,
      gsize size,
      GDestroyNotify destroy_notify,
      gpointer user_data
    )

#### Description [src]

Creates a new %ArrayBuffer from existing `data` in memory.

The `data` is not copied: while this allows sharing data with JavaScript efficiently, the caller must ensure that the memory region remains valid until the newly created object is released by JSC.

Optionally, a `destroy_notify` callback can be provided, which will be invoked with `user_data` as parameter when the %ArrayBuffer object is released. This is intended to be used for freeing resources related to the memory region which contains the data:

|[!<— language=”C” —> GMappedFile f = g_mapped_file_new (file_path, TRUE, NULL); JSCValue value = jsc_value_new_array_buffer (context, g_mapped_file_get_contents (f), g_mapped_file_get_length (f), (GDestroyNotify) g_mapped_file_unref, f); ]|

Note that the `user_data` can be the same value as `data`:

|[!<— language=”C” —> void bytes = g_malloc0 (100); JSCValue value = jsc_value_new_array_buffer (context, bytes, 100, g_free, bytes); ]|

Available since: 2.38

#### Parameters

`context`

  Type: `JSCContext`

  A `JSCContext`.

  The data is owned by the caller of the function.

`data`

  Type: `gpointer`

  Pointer to a region of memory.

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

`size`

  Type: `gsize`

  Size in bytes of the memory region.

`destroy_notify`

  Type: `GDestroyNotify`

  Destroy notifier for `user_data`.

  The argument can be `NULL`.

`user_data`

  Type: `gpointer`

  User data.

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

#### Return value

Type: `JSCValue`

A `JSCValue`, or `NULL` in case of exception.

The caller of the function takes ownership of the data, and is responsible for freeing it.
The return value can be `NULL`.