GLib.PtrArray.free
Description: Reference for GLib.PtrArray.free

### Function

# GLib PtrArrayfree

#### Declaration [src]

    gpointer*
    g_ptr_array_free (
      GPtrArray* array,
      gboolean free_segment
    )

#### Description [src]

Frees the memory allocated for the `GPtrArray`. If `free_segment` is true it frees the memory block holding the elements as well. Pass false if you want to free the `GPtrArray` wrapper but preserve the underlying array for use elsewhere. If the reference count of `array` is greater than one, the `GPtrArray` wrapper is preserved but the size of `array` will be set to zero.

If array contents point to dynamically-allocated memory, they should be freed separately if `free_segment` is true and no `GDestroyNotify` function has been set for `array`.

Note that if the array is `NULL` terminated and `free_segment` is false then this will always return an allocated `NULL` terminated buffer. If `pdata` is previously `NULL`, a new buffer will be allocated.

This function is not thread-safe. If using a `GPtrArray` from multiple threads, use only the atomic `g_ptr_array_ref()` and `g_ptr_array_unref()` functions.

This function is not directly available to language bindings.

#### Parameters

`array`

  Type: An array of `gpointer`

  A pointer array.

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

`free_segment`

  Type: `gboolean`

  If true, the actual pointer array is freed as well.

#### Return value

Type: An array of `gpointer`

The allocated pointer array if `free_segment` is false, otherwise `NULL`.

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