Go to the documentation of this file.
   20 #ifndef __PIPEWIRE_ARRAY_H__ 
   21 #define __PIPEWIRE_ARRAY_H__ 
   27 #include <spa/utils/defs.h> 
   43 #define PW_ARRAY_INIT(extend) (struct pw_array) { NULL, 0, 0, extend } 
   45 #define pw_array_get_len_s(a,s)                 ((a)->size / (s)) 
   46 #define pw_array_get_unchecked_s(a,idx,s,t)     SPA_MEMBER((a)->data,(idx)*(s),t) 
   47 #define pw_array_check_index_s(a,idx,s)         ((idx) < pw_array_get_len_s(a,s)) 
   50 #define pw_array_get_len(a,t)                   pw_array_get_len_s(a,sizeof(t)) 
   52 #define pw_array_get_unchecked(a,idx,t)         pw_array_get_unchecked_s(a,idx,sizeof(t),t) 
   54 #define pw_array_check_index(a,idx,t)           pw_array_check_index_s(a,idx,sizeof(t)) 
   56 #define pw_array_for_each(pos, array)                                                   \ 
   57         for (pos = (__typeof__(pos)) (array)->data;                                                     \ 
   58              (const uint8_t *) pos < ((const uint8_t *) (array)->data + (array)->size); \ 
   70 static inline void pw_array_clear(
struct pw_array *arr)
 
   81         need = arr->
size + size;
 
   83         if (SPA_UNLIKELY(alloc < need)) {
 
   85                 alloc = SPA_MAX(alloc, arr->
extend);
 
   88                 if (SPA_UNLIKELY((data = realloc(arr->
data, alloc)) == NULL))
 
  105         p = SPA_MEMBER(arr->
data, arr->
size, 
void);
 
  117         if (SPA_UNLIKELY(arr->
alloc < arr->
size + size))
 
  120         p = SPA_MEMBER(arr->
data, arr->
size, 
void);
 
  127 #define pw_array_add_ptr(a,p)                                   \ 
  128         *((void**) pw_array_add(a, sizeof(void*))) = (p) 
  
 
size_t alloc
number of allocated memory in data
Definition: array.h:39
static bool pw_array_ensure_size(struct pw_array *arr, size_t size)
Make sure size bytes can be added to the array.
Definition: array.h:76
size_t size
length of array in bytes
Definition: array.h:38
size_t extend
number of bytes to extend with
Definition: array.h:40
An array object.
Definition: array.h:36
static void * pw_array_add_fixed(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:113
static void * pw_array_add(struct pw_array *arr, size_t size)
Add ref size bytes to arr.
Definition: array.h:98
void * data
pointer to array data
Definition: array.h:37
static void pw_array_init(struct pw_array *arr, size_t extend)
Initialize the array with given extend.
Definition: array.h:62