Method

GLibBytesnew_from_bytes

since: 2.32

Declaration [src]

GBytes*
g_bytes_new_from_bytes (
  GBytes* bytes,
  gsize offset,
  gsize length
)

Description [src]

Creates a GBytes which is a subsection of another GBytes.

The offset + length may not be longer than the size of bytes.

A reference to bytes will be held by the newly created GBytes until the byte data is no longer needed.

Since 2.56, if offset is 0 and length matches the size of bytes, then bytes will be returned with the reference count incremented by 1. If bytes is a slice of another GBytes, then the resulting GBytes will reference the same GBytes instead of bytes. This allows consumers to simplify the usage of GBytes when asynchronously writing to streams.

Available since: 2.32

Parameters

offset

Type: gsize

Offset which subsection starts at.

length

Type: gsize

Length of subsection.

Return value

Type: GBytes

A new GBytes.

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