### Function

# GLib try_malloc

since: 2.0

#### Declaration

    gpointer
    g_try_malloc (
      gsize n_bytes
    )

#### Description

Attempts to allocate `n_bytes`, and returns `NULL` on failure. Contrast with g_malloc(), which aborts the program on failure.

Available since: 2.0

#### Parameters

`n_bytes`

  Type: `gsize`

  Number of bytes to allocate.

#### Return value

Type: `gpointer`

The allocated memory, or `NULL`.

The data is owned by the called function.
The return value can be `NULL`.