Function

GLibBytesnew_take

Declaration

GBytes*
g_bytes_new_take (
  gpointer data,
  gsize size
)

Description

Creates a new GBytes from data.

After this call, data belongs to the bytes and may no longer be modified by the caller. g_free() will be called on data when the bytes is no longer in use. Because of this data must have been created by a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many functions that wrap these calls (such as g_new(), g_strdup(), etc).

For creating GBytes with memory from other allocators, see g_bytes_new_with_free_func().

data may be NULL if size is 0.

Available since:2.32

Parameters

data

Type: An array of guint8

   the data to be used for the bytes.

The length of the array is specified in the size argument.
size

Type: gsize

The size of data.

Return value

Type: GBytes

A new GBytes.

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