GLib.String.free_to_bytes

### Method

# GLib Stringfree_to_bytes

since: 2.34

#### Declaration [src]

    GBytes*
    g_string_free_to_bytes (
      GString* string
    )

#### Description [src]

Transfers ownership of the contents of `string` to a newly allocated `GBytes`. The `GString` structure itself is deallocated, and it is therefore invalid to use `string` after invoking this function.

Note that while `GString` ensures that its buffer always has a trailing nul character (not reflected in its “len”), the returned `GBytes` does not include this extra nul; i.e. it has length exactly equal to the “len” member.

Available since: 2.34

#### Parameters

`string`

  Type: `GString`

  A `GString`.

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

#### Return value

Type: `GBytes`

A newly allocated `GBytes` containing contents of `string`; `string` itself is freed.

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