Struct

GLibByteArray

Description [src]

struct GByteArray {
  guint8* data;
  guint len;
}

Contains the public fields of a GByteArray.

Structure members
data

A pointer to the element data. The data may be moved as elements are added to the GByteArray.

len

The number of elements in the GByteArray.

Functions

g_byte_array_append

Adds the given bytes to the end of the GByteArray. The array will grow in size automatically if necessary.

g_byte_array_free

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.

g_byte_array_free_to_bytes

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

since: 2.32

g_byte_array_new

Creates a new GByteArray with a reference count of 1.

g_byte_array_new_take

Creates a byte array containing the data. After this call, data belongs to the GByteArray and may no longer be modified by the caller. The memory of data has to be dynamically allocated and will eventually be freed with g_free().

since: 2.32

g_byte_array_prepend

Adds the given data to the start of the GByteArray. The array will grow in size automatically if necessary.

g_byte_array_ref

Atomically increments the reference count of array by one. This function is thread-safe and may be called from any thread.

since: 2.22

g_byte_array_remove_index

Removes the byte at the given index from a GByteArray. The following bytes are moved down one place.

g_byte_array_remove_index_fast

Removes the byte at the given index from a GByteArray. The last element in the array is used to fill in the space, so this function does not preserve the order of the GByteArray. But it is faster than g_byte_array_remove_index().

g_byte_array_remove_range

Removes the given number of bytes starting at the given index from a GByteArray. The following elements are moved to close the gap.

since: 2.4

g_byte_array_set_size

Sets the size of the GByteArray, expanding it if necessary.

g_byte_array_sized_new

Creates a new GByteArray with reserved_size bytes preallocated. This avoids frequent reallocation, if you are going to add many bytes to the array. Note however that the size of the array is still 0.

g_byte_array_sort

Sorts a byte array, using compare_func which should be a qsort()-style comparison function (returns less than zero for first arg is less than second arg, zero for equal, greater than zero if first arg is greater than second arg).

g_byte_array_sort_with_data

Like g_byte_array_sort(), but the comparison function takes an extra user data argument.

g_byte_array_steal

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.

since: 2.64

g_byte_array_unref

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.

since: 2.22