diff options
-rw-r--r-- | src/list.c | 14 | ||||
-rw-r--r-- | src/list.h | 2 |
2 files changed, 10 insertions, 6 deletions
@@ -103,13 +103,17 @@ clist_iterator_has_next(iterator_t i) return i.current != NULL; } -list_item_t -clist_iterator_next(iterator_t *iterator) +void * +clist_iterator_next(iterator_t *i) { - struct list_item_t *current = iterator->current; - iterator->current = iterator->current->next; + if (i == NULL || i->current == NULL) + return NULL; - return current; + void *data = i->current->data; + /* `next` can be NULL */ + i->current = i->current->next; + + return data; } char * @@ -41,7 +41,7 @@ void clist_add_all (list_t *, list_t *); void clist_remove (list_t *, list_item_t *); iterator_t clist_iterator (list_t *); int clist_iterator_has_next(iterator_t); -list_item_t *clist_iterator_next (iterator_t *); +void *clist_iterator_next (iterator_t *); char* clist_version (void); #endif |