DOKK / manpages / debian 12 / libwayland-doc / wl_array.3.en
wl_array(3) Wayland wl_array(3)

wl_array

#include <wayland-util.h>


void wl_array_init (struct wl_array *array)
void wl_array_release (struct wl_array *array)
void * wl_array_add (struct wl_array *array, size_t size)
int wl_array_copy (struct wl_array *array, struct wl_array *source)


size_t size
size_t alloc
void * data

(Note that these are not member functions.)
#define wl_array_for_each(pos, array)

Dynamic array

A wl_array is a dynamic array that can only grow until released. It is intended for relatively small allocations whose size is variable or not known in advance. While construction of a wl_array does not require all elements to be of the same size, wl_array_for_each() does require all elements to have the same type and size.

Increases the size of the array by size bytes.

Parameters

array Array whose size is to be increased
size Number of bytes to increase the size of the array by

Returns

A pointer to the beginning of the newly appended space, or NULL when resizing fails.

Copies the contents of source to array.

Parameters

array Destination array to copy to
source Source array to copy from

Returns

0 on success, or -1 on failure

Initializes the array.

Parameters

array Array to initialize

Releases the array data.

Note

Leaves the array in an invalid state.

Parameters

array Array whose data is to be released

Value:


for (pos = (array)->data; (const char *) pos < ((const char *) (array)->data + (array)->size); (pos)++)
Iterates over an array.

This macro expresses a for-each iterator for wl_array. It assigns each element in the array to pos, which can then be referenced in a trailing code block. pos must be a pointer to the array element type, and all array elements must be of the same type and size.

Parameters

pos Cursor that each array element will be assigned to
array Array to iterate over

See also

wl_list_for_each()

Allocated space

Array data

Array size

Generated automatically by Doxygen for Wayland from the source code.

Fri Jul 8 2022 Version 1.21.0