1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-09-22 04:15:55 -04:00

Feature: Added igloo_list_clear()

This commit is contained in:
Philipp Schafft 2018-11-08 13:14:22 +00:00
parent 4b579f596c
commit 28fea532cf
2 changed files with 14 additions and 0 deletions

View File

@ -45,6 +45,7 @@ struct igloo_list_iterator_tag {
* Those types are defined here as they must be known to the compiler.
* Nobody should ever try to access them directly.
*/
int igloo_list_clear(igloo_list_t *list);
void igloo_list_preallocate(igloo_list_t *list, size_t request);
int igloo_list_set_type__real(igloo_list_t *list, const igloo_ro_type_t *type);
#define igloo_list_set_type(list,type) igloo_list_set_type__real((list),(igloo_ro__type__ ## type))

View File

@ -44,11 +44,24 @@ igloo_RO_PUBLIC_TYPE(igloo_list_t,
static void __free(igloo_ro_t self)
{
igloo_list_t *list = igloo_RO_TO_TYPE(self, igloo_list_t);
igloo_list_clear(list);
}
int igloo_list_clear(igloo_list_t *list)
{
size_t i;
if (!igloo_RO_IS_VALID(list, igloo_list_t))
return -1;
for (i = list->offset; i < list->fill; i++) {
igloo_ro_unref(list->elements[i]);
}
list->offset = 0;
list->fill = 0;
return 0;
}
static inline void igloo_list_preallocate__realign(igloo_list_t *list)