PipeWire 1.1.0
Loading...
Searching...
No Matches

An array object. More...

Files

file  array.h
 pipewire/array.h
 

Data Structures

struct  pw_array
 

Macros

#define PW_ARRAY_INIT(extend)   ((struct pw_array) { NULL, 0, 0, (extend) })
 Initialize an array.
 
#define pw_array_get_len_s(a, s)   ((a)->size / (s))
 Return the length of an array.
 
#define pw_array_get_unchecked_s(a, idx, s, t)   SPA_PTROFF((a)->data,(idx)*(s),t)
 
#define pw_array_check_index_s(a, idx, s)   ((idx) < pw_array_get_len_s(a,s))
 
#define pw_array_get_len(a, t)   pw_array_get_len_s(a,sizeof(t))
 Get the number of items of type t in array.
 
#define pw_array_get_unchecked(a, idx, t)   pw_array_get_unchecked_s(a,idx,sizeof(t),t)
 Get the item with index idx and type t from array.
 
#define pw_array_check_index(a, idx, t)   pw_array_check_index_s(a,idx,sizeof(t))
 Check if an item with index idx and type t exist in array.
 
#define pw_array_first(a)   ((a)->data)
 
#define pw_array_end(a)   SPA_PTROFF((a)->data, (a)->size, void)
 
#define pw_array_check(a, p)   (SPA_PTROFF(p,sizeof(*(p)),void) <= pw_array_end(a))
 
#define pw_array_for_each(pos, array)
 
#define pw_array_consume(pos, array)
 
#define pw_array_remove(a, p)
 

Functions

static void pw_array_init (struct pw_array *arr, size_t extend)
 Initialize the array with given extend.
 
static void pw_array_clear (struct pw_array *arr)
 Clear the array.
 
static void pw_array_init_static (struct pw_array *arr, void *data, size_t size)
 Initialize a static array.
 
static void pw_array_reset (struct pw_array *arr)
 Reset the array.
 
static int pw_array_ensure_size (struct pw_array *arr, size_t size)
 Make sure size bytes can be added to the array.
 
static void * pw_array_add (struct pw_array *arr, size_t size)
 Add ref size bytes to arr.
 
static int pw_array_add_ptr (struct pw_array *arr, void *ptr)
 Add a pointer to array.
 

Detailed Description

An array object.

The array is a dynamically resizable data structure that can hold items of the same size.

Macro Definition Documentation

◆ PW_ARRAY_INIT

#define PW_ARRAY_INIT (   extend)    ((struct pw_array) { NULL, 0, 0, (extend) })

Initialize an array.

The new array is empty.

◆ pw_array_get_len_s

#define pw_array_get_len_s (   a,
 
)    ((a)->size / (s))

Return the length of an array.

◆ pw_array_get_unchecked_s

#define pw_array_get_unchecked_s (   a,
  idx,
  s,
 
)    SPA_PTROFF((a)->data,(idx)*(s),t)

◆ pw_array_check_index_s

#define pw_array_check_index_s (   a,
  idx,
 
)    ((idx) < pw_array_get_len_s(a,s))

◆ pw_array_get_len

#define pw_array_get_len (   a,
 
)    pw_array_get_len_s(a,sizeof(t))

Get the number of items of type t in array.

◆ pw_array_get_unchecked

#define pw_array_get_unchecked (   a,
  idx,
 
)    pw_array_get_unchecked_s(a,idx,sizeof(t),t)

Get the item with index idx and type t from array.

No bounds check is done.

◆ pw_array_check_index

#define pw_array_check_index (   a,
  idx,
 
)    pw_array_check_index_s(a,idx,sizeof(t))

Check if an item with index idx and type t exist in array.

◆ pw_array_first

#define pw_array_first (   a)    ((a)->data)

◆ pw_array_end

#define pw_array_end (   a)    SPA_PTROFF((a)->data, (a)->size, void)

◆ pw_array_check

#define pw_array_check (   a,
 
)    (SPA_PTROFF(p,sizeof(*(p)),void) <= pw_array_end(a))

◆ pw_array_for_each

#define pw_array_for_each (   pos,
  array 
)

◆ pw_array_consume

#define pw_array_consume (   pos,
  array 
)

◆ pw_array_remove

#define pw_array_remove (   a,
 
)

Function Documentation

◆ pw_array_init()

static void pw_array_init ( struct pw_array arr,
size_t  extend 
)
inlinestatic

Initialize the array with given extend.

Extend needs to be > 0 or else the array will not be able to expand.

◆ pw_array_clear()

static void pw_array_clear ( struct pw_array arr)
inlinestatic

Clear the array.

This should be called when pw_array_init() was called.

◆ pw_array_init_static()

static void pw_array_init_static ( struct pw_array arr,
void *  data,
size_t  size 
)
inlinestatic

Initialize a static array.

◆ pw_array_reset()

static void pw_array_reset ( struct pw_array arr)
inlinestatic

Reset the array.

◆ pw_array_ensure_size()

static int pw_array_ensure_size ( struct pw_array arr,
size_t  size 
)
inlinestatic

Make sure size bytes can be added to the array.

◆ pw_array_add()

static void * pw_array_add ( struct pw_array arr,
size_t  size 
)
inlinestatic

Add ref size bytes to arr.

A pointer to memory that can hold at least size bytes is returned or NULL when an error occured and errno will be set.

◆ pw_array_add_ptr()

static int pw_array_add_ptr ( struct pw_array arr,
void *  ptr 
)
inlinestatic

Add a pointer to array.

Returns 0 on success and a negative errno style error on failure.