/** *\addtogrouppw_array *\{
*/ struct pw_array { void *data; /**< pointer to array data */
size_t size; /**< length of array in bytes */
size_t alloc; /**< number of allocated memory in \a data */
size_t extend; /**< number of bytes to extend with, 0 when the
* data should not expand */
};
/** Initialize an array. The new array is empty. */ #define PW_ARRAY_INIT(extend) ((struct pw_array) { NULL, 0, 0, (extend) })
/** Return the length of an array. */ #define pw_array_get_len_s(a,s) ((a)->size / (s)) #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))
/** Get the number of items of type \a t in array */ #define pw_array_get_len(a,t) pw_array_get_len_s(a,sizeof(t)) /** Get the item with index \a idx and type \a t from array. No bounds check is done. */ #define pw_array_get_unchecked(a,idx,t) pw_array_get_unchecked_s(a,idx,sizeof(t),t) /** Check if an item with index \a idx and type \a t exist in array */ #define pw_array_check_index(a,idx,t) pw_array_check_index_s(a,idx,sizeof(t))
/** Initialize the array with given extend. Extend needs to be > 0 or else
* the array will not be able to expand. */
PW_API_ARRAY void pw_array_init(struct pw_array *arr, size_t extend)
{
arr->data = NULL;
arr->size = arr->alloc = 0;
arr->extend = extend;
}
/** Clear the array. This should be called when pw_array_init() was called. */
PW_API_ARRAY void pw_array_clear(struct pw_array *arr)
{ if (arr->extend > 0)
free(arr->data);
pw_array_init(arr, arr->extend);
}
/** Make sure \a size bytes can be added to the array */
PW_API_ARRAY int pw_array_ensure_size(struct pw_array *arr, size_t size)
{
size_t alloc, need;
/** Add \a ref size bytes to \a arr. A pointer to memory that can *holdatleast\asizebytesisreturnedorNULLwhenanerroroccurred
* and errno will be set.*/
PW_API_ARRAY void *pw_array_add(struct pw_array *arr, size_t size)
{ void *p;
if (pw_array_ensure_size(arr, size) < 0) return NULL;
p = SPA_PTROFF(arr->data, arr->size, void);
arr->size += size;
return p;
}
/** Add a pointer to array. Returns 0 on success and a negative errno style
* error on failure. */
PW_API_ARRAY int pw_array_add_ptr(struct pw_array *arr, void *ptr)
{ void **p = (void **)pw_array_add(arr, sizeof(void*)); if (p == NULL) return -errno;
*p = ptr; return0;
}
/** *\}
*/
#ifdef __cplusplus
} /* extern "C" */ #endif
#endif/* PIPEWIRE_ARRAY_H */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.