mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
dynarray: Add PA_DYNARRAY_FOREACH
The PA_DYNARRAY_FOREACH macro requires that pa_dynarray_get() returns NULL if the index is out of bounds.
This commit is contained in:
parent
7d3879c07f
commit
360cb6550e
3 changed files with 8 additions and 4 deletions
|
|
@ -43,6 +43,8 @@ pa_dynarray* pa_dynarray_new(pa_free_cb_t free_cb);
|
|||
void pa_dynarray_free(pa_dynarray *array);
|
||||
|
||||
void pa_dynarray_append(pa_dynarray *array, void *p);
|
||||
|
||||
/* Returns the element at index i, or NULL if i is out of bounds. */
|
||||
void *pa_dynarray_get(pa_dynarray *array, unsigned i);
|
||||
|
||||
/* Returns the last element, or NULL if the array is empty. */
|
||||
|
|
@ -61,4 +63,7 @@ void *pa_dynarray_steal_last(pa_dynarray *array);
|
|||
|
||||
unsigned pa_dynarray_size(pa_dynarray *array);
|
||||
|
||||
#define PA_DYNARRAY_FOREACH(elem, array, idx) \
|
||||
for ((idx) = 0; ((elem) = pa_dynarray_get(array, idx)); (idx)++)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue