<GByteArray>

<GByteArray>

Description

Contains the public fields of a GByteArray.

Functions

byte-array:free

(define-values (%return) (byte-array:free array free-segment))

Frees the memory allocated by the GByteArray. If free_segment is TRUE it frees the actual byte data. If the reference count of array is greater than one, the GByteArray wrapper is preserved but the size of array will be set to zero.

Parameters

array

a GByteArray

Passed as array

free_segment

if TRUE the actual byte data is freed as well

Passed as free-segment

byte-array:free-to-bytes

(define-values (%return) (byte-array:free-to-bytes array))

Transfers the data from the GByteArray into a new immutable GBytes.

The GByteArray is freed unless the reference count of array is greater than one, the GByteArray wrapper is preserved but the size of array will be set to zero.

This is identical to using g_bytes_new_take() and g_byte_array_free() together.

Parameters

array

a GByteArray

Passed as array

byte-array:new

(define-values (%return) (byte-array:new))

Creates a new GByteArray with a reference count of 1.

byte-array:new-take

(define-values (%return) (byte-array:new-take data))

Create byte array containing the data. The data will be owned by the array and will be freed with g_free(), i.e. it could be allocated using g_strdup().

Parameters

data

byte data for the array

Passed as data

len

length of data

Inferred from data

byte-array:steal

(define-values (%return len) (byte-array:steal array len))

Frees the data in the array and resets the size to zero, while the underlying array is preserved for use elsewhere and returned to the caller.

Parameters

array

a GByteArray.

Passed as array

len

pointer to retrieve the number of elements of the original array

Passed as len

byte-array:unref

(define-values () (byte-array:unref array))

Atomically decrements the reference count of array by one. If the reference count drops to 0, all memory allocated by the array is released. This function is thread-safe and may be called from any thread.

Parameters

array

A GByteArray

Passed as array