Commit 25d8229f 25d8229ffad5f3343a155d20e3a8c164d6dd65aa by Sergey Poznyakoff

(iterator_dup): New function

1 parent 9192cc90
...@@ -25,6 +25,7 @@ extern "C" { ...@@ -25,6 +25,7 @@ extern "C" {
25 #endif 25 #endif
26 26
27 extern int iterator_create __P ((iterator_t *, list_t)); 27 extern int iterator_create __P ((iterator_t *, list_t));
28 extern int iterator_dup __P ((iterator_t *piterator, iterator_t orig));
28 extern void iterator_destroy __P ((iterator_t *)); 29 extern void iterator_destroy __P ((iterator_t *));
29 extern int iterator_first __P ((iterator_t)); 30 extern int iterator_first __P ((iterator_t));
30 extern int iterator_next __P ((iterator_t)); 31 extern int iterator_next __P ((iterator_t));
......
...@@ -43,6 +43,25 @@ iterator_create (iterator_t *piterator, list_t list) ...@@ -43,6 +43,25 @@ iterator_create (iterator_t *piterator, list_t list)
43 return 0; 43 return 0;
44 } 44 }
45 45
46 int
47 iterator_dup (iterator_t *piterator, iterator_t orig)
48 {
49 iterator_t iterator;
50
51 if (piterator == NULL || orig == NULL)
52 return EINVAL;
53 iterator = calloc (sizeof (*iterator), 1);
54 if (iterator == NULL)
55 return ENOMEM;
56 iterator->list = orig->list;
57 iterator->cur = orig->cur;
58 iterator->is_advanced = orig->is_advanced;
59 iterator->next = orig->list->itr;
60 orig->list->itr = iterator;
61 *piterator = iterator;
62 return 0;
63 }
64
46 void 65 void
47 iterator_destroy (iterator_t *piterator) 66 iterator_destroy (iterator_t *piterator)
48 { 67 {
......