(iterator_dup): New function
Showing
2 changed files
with
20 additions
and
0 deletions
... | @@ -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 | { | ... | ... |
-
Please register or sign in to post a comment