diff options
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index e7ec2de91..392aa09de 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -580,10 +580,21 @@ struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) .c = c, .flags = flags }; + + ao2_ref(c, +1); return a; } +/*! + * destroy an iterator + */ +void ao2_iterator_destroy(struct ao2_iterator *i) +{ + ao2_ref(i->c, -1); + i->c = NULL; +} + /* * move to the next element in the container. */ @@ -596,7 +607,7 @@ void * ao2_iterator_next(struct ao2_iterator *a) if (INTERNAL_OBJ(a->c) == NULL) return NULL; - if (!(a->flags & F_AO2I_DONTLOCK)) + if (!(a->flags & AO2_ITERATOR_DONTLOCK)) ao2_lock(a->c); /* optimization. If the container is unchanged and @@ -637,7 +648,7 @@ found: ao2_ref(ret, 1); } - if (!(a->flags & F_AO2I_DONTLOCK)) + if (!(a->flags & AO2_ITERATOR_DONTLOCK)) ao2_unlock(a->c); return ret; |