array: add and use pw_array_consume

This commit is contained in:
Wim Taymans 2020-05-06 15:56:31 +02:00
parent 720b7b5c6a
commit 649448fb5f
2 changed files with 6 additions and 7 deletions

View file

@ -145,14 +145,8 @@ static int clear_subjects(struct metadata *this, uint32_t subject)
static void clear_items(struct metadata *this)
{
struct item *item;
while (true) {
item = pw_array_first(&this->metadata);
if (!pw_array_check(&this->metadata, item))
break;
pw_array_consume(item, &this->metadata)
clear_subjects(this, item->subject);
}
pw_array_reset(&this->metadata);
}

View file

@ -69,6 +69,11 @@ struct pw_array {
pw_array_check(array, pos); \
(pos)++)
#define pw_array_consume(pos, array) \
for (pos = (__typeof__(pos)) pw_array_first(array); \
pw_array_check(array, pos); \
pos = (__typeof__(pos)) pw_array_first(array))
#define pw_array_remove(a,p) \
({ \
(a)->size -= sizeof(*(p)); \