Hex.Buffer.util_new
Description: Reference for Hex.Buffer.util_new

### Function

# Hex Bufferutil_new

#### Declaration

    HexBuffer*
    hex_buffer_util_new (
      const char* plugin,
      GFile* file
    )

#### Description

Utility function to create an on object which implements the HexBuffer interface.

The `plugin` parameter will be the unique part of the plugin file name (eg, if the file name is libhex-buffer-mmap.so, you would specify “mmap”). If `NULL` is passed, the fallback (presently the “malloc” backend, but this is an implementation detail and may be subject to change) will be used.

The `file` parameter is a valid `GFile` if you would like the buffer pre-loaded, or `NULL` for an empty buffer.

#### Parameters

`plugin`

  Type: `const char*`

  The name of the plugin, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`file`

  Type: `GFile`

  File to initialize the buffer with, or `NULL`.

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

#### Return value

Type: `HexBuffer`

A pointer to a valid implementation of a `HexBuffer` interface, pre-cast as type `HexBuffer`, or `NULL` if the operation failed. Starting with 4.2, if a specific backend is requested, and the system supports plugins as a whole but cannot load that specified plugin, `NULL` will be returned as though the operation failed, so as to customize the fallback scheme programmatically.

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