mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-22 06:59:59 -05:00
list: add _consume method
Add safer way to destroy a list of objects.
This commit is contained in:
parent
fa0b4f9321
commit
2b5c6fd676
11 changed files with 43 additions and 38 deletions
|
|
@ -78,6 +78,11 @@ static inline void spa_list_remove(struct spa_list *elem)
|
|||
#define spa_list_next(pos, member) \
|
||||
SPA_CONTAINER_OF((pos)->member.next, __typeof__(*pos), member)
|
||||
|
||||
#define spa_list_consume(pos, head, member) \
|
||||
for (pos = spa_list_first(head, __typeof__(*pos), member); \
|
||||
!spa_list_is_empty(head); \
|
||||
pos = spa_list_first(head, __typeof__(*pos), member))
|
||||
|
||||
#define spa_list_for_each_next(pos, head, curr, member) \
|
||||
for (pos = spa_list_first(curr, __typeof__(*pos), member); \
|
||||
!spa_list_is_end(pos, head, member); \
|
||||
|
|
|
|||
|
|
@ -686,13 +686,13 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *impl;
|
||||
struct source_impl *source, *tmp;
|
||||
struct source_impl *source;
|
||||
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
impl = (struct impl *) handle;
|
||||
|
||||
spa_list_for_each_safe(source, tmp, &impl->source_list, link)
|
||||
spa_list_consume(source, &impl->source_list, link)
|
||||
loop_destroy_source(&source->source);
|
||||
|
||||
process_destroy(impl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue