wl_array(3)

🌸 NAME 🌸

wl_array β€” bestie, this is the manual page for the dynamic array queen herself, wl_array(3), from the library functions manual. She’s giving grow-only icon energy, and she’s here to hold your variable-sized little collection. πŸ’–

✨ SYNOPSIS ✨

#include <wayland-util.h>

πŸ’… Public Member Functions πŸ’…

  • void wl_array_init (struct wl_array *array) β€” initializes the array. Gets it set up and ready, bestie.
  • void wl_array_release (struct wl_array *array) β€” releases the array data. Heads up: this leaves the array in an invalid state, details below. πŸ’€
  • void * wl_array_add (struct wl_array *array, size_t size) β€” increases the array size by size bytes and hands you a pointer to the new space.
  • int wl_array_copy (struct wl_array *array, struct wl_array *source) β€” copies the contents of source into array.

πŸ“¦ Data Fields πŸ“¦

  • size_t size β€” array size.
  • size_t alloc β€” allocated space.
  • void * data β€” array data.
Not me reminding you: these are not member symbols. The original note is β€œ(Note that these are not member symbols.)” β€” so don’t get it twisted, bestie. πŸ’…
  • #define wl_array_for_each(pos, array) β€” the for-each macro, with full details down below.

πŸ¦‹ Detailed Description πŸ¦‹

Dynamic array, periodt. A wl_array is a dynamic array that can only grow until it’s released. It’s 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. No cap.

πŸ’– Member Function Documentation πŸ’–

void * wl_array_add (struct wl_array * array, size_t size)

Increases the size of the array by size bytes. Slay.

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. If it’s NULL, that’s the vibe check failing, fr fr.

int wl_array_copy (struct wl_array * array, struct wl_array * source)

Copies the contents of source to array. Iconic copy-paste behavior. 🫢

Parameters

  • array β€” Destination array to copy to
  • source β€” Source array to copy from

Returns: 0 on success, or -1 on failure.

void wl_array_init (struct wl_array * array)

Initializes the array.

Parameters

  • array β€” Array to initialize

void wl_array_release (struct wl_array * array)

Releases the array data.

Note: Leaves the array in an invalid state. That’s the note, bestie β€” it’s invalid after this, so don’t act brand new. 😭

Parameters

  • array β€” Array whose data is to be released

Value:

for (pos = (array)->data;                                       \
     (array)->size != 0 &&                                      \
     (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()

πŸ“ Field Documentation πŸ“

size_t wl_array::alloc

Allocated space.

void* wl_array::data

Array data.

size_t wl_array::size

Array size.

πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for Wayland from the source code.


Signed off from Wayland, Version 1.26.0, for wl_array(3) β€” and the footer didn’t give me a date, so I’m not inventing one, bestie. Periodt. πŸ’…πŸ’–

πŸ“¦ where this page comes from