1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-11-03 04:17:20 -05:00

Feature: Added igloo_list_forward()

This commit is contained in:
Philipp Schafft 2019-09-12 09:27:52 +00:00
parent 337be51863
commit eeb46eb889
2 changed files with 18 additions and 0 deletions

View File

@ -85,6 +85,9 @@ int igloo_list_merge(igloo_list_t *list, igloo_list_t *eleme
*/
int igloo_list_remove(igloo_list_t *list, igloo_ro_t element);
/* Forward all the objects in the list to the given object handler */
int igloo_list_forward(igloo_list_t *list, igloo_objecthandler_t *handler);
/* Creates a new iterator that can be used to walk the list.
* The memory pointed to by storage of size storage_length is used to store the iterator's internal
* values. It must be allocated (e.g. on stack) untill igloo_list_iterator_end() is called.

View File

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <igloo/list.h>
#include <igloo/objecthandler.h>
struct igloo_list_tag {
igloo_ro_base_t __base;
@ -413,6 +414,20 @@ int igloo_list_remove(igloo_list_t *list, igloo_ro_t element
return -1;
}
int igloo_list_forward(igloo_list_t *list, igloo_objecthandler_t *handler)
{
size_t i;
if (!igloo_RO_IS_VALID(list, igloo_list_t) || !igloo_RO_IS_VALID(handler, igloo_objecthandler_t))
return -1;
for (i = list->offset; i < list->fill; i++) {
igloo_objecthandler_handle(handler, list->elements[i]);
}
return 0;
}
igloo_list_iterator_t * igloo_list_iterator_start(igloo_list_t *list, void *storage, size_t storage_length)
{
igloo_list_iterator_t *iterator;