Commit 25d8229f 25d8229ffad5f3343a155d20e3a8c164d6dd65aa by Sergey Poznyakoff

(iterator_dup): New function

1 parent 9192cc90
......@@ -25,6 +25,7 @@ extern "C" {
#endif
extern int iterator_create __P ((iterator_t *, list_t));
extern int iterator_dup __P ((iterator_t *piterator, iterator_t orig));
extern void iterator_destroy __P ((iterator_t *));
extern int iterator_first __P ((iterator_t));
extern int iterator_next __P ((iterator_t));
......
......@@ -43,6 +43,25 @@ iterator_create (iterator_t *piterator, list_t list)
return 0;
}
int
iterator_dup (iterator_t *piterator, iterator_t orig)
{
iterator_t iterator;
if (piterator == NULL || orig == NULL)
return EINVAL;
iterator = calloc (sizeof (*iterator), 1);
if (iterator == NULL)
return ENOMEM;
iterator->list = orig->list;
iterator->cur = orig->cur;
iterator->is_advanced = orig->is_advanced;
iterator->next = orig->list->itr;
orig->list->itr = iterator;
*piterator = iterator;
return 0;
}
void
iterator_destroy (iterator_t *piterator)
{
......