mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2025-02-02 15:07:47 -05:00
Feature: Added igloo_list_forward()
This commit is contained in:
parent
337be51863
commit
eeb46eb889
@ -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);
|
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.
|
/* 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
|
* 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.
|
* values. It must be allocated (e.g. on stack) untill igloo_list_iterator_end() is called.
|
||||||
|
15
src/list.c
15
src/list.c
@ -24,6 +24,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <igloo/list.h>
|
#include <igloo/list.h>
|
||||||
|
#include <igloo/objecthandler.h>
|
||||||
|
|
||||||
struct igloo_list_tag {
|
struct igloo_list_tag {
|
||||||
igloo_ro_base_t __base;
|
igloo_ro_base_t __base;
|
||||||
@ -413,6 +414,20 @@ int igloo_list_remove(igloo_list_t *list, igloo_ro_t element
|
|||||||
return -1;
|
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 * igloo_list_iterator_start(igloo_list_t *list, void *storage, size_t storage_length)
|
||||||
{
|
{
|
||||||
igloo_list_iterator_t *iterator;
|
igloo_list_iterator_t *iterator;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user