C Collections

citerators · Section 3

ccol_iter_destroy

ccol_iter_destroy - destroy a unified iterator before the end

C Collections (libccollections, -lccollections)

#include <ccollections/citerators.h>   /* or any container header */
 
ccol_iter_destroy(it);

ccol_iter_destroy calls the ccol__free_fn callback of the iterator and then
sets it to NULL. Call it where your own for loop breaks out, so the
iterator doesn't stay alive until the end of the scope.
 
An iterator from ccol_iter_declare() is destroyed by its RAII cleanup at
the end of the scope anyway, so you need ccol_iter_destroy() only when
the resources have to be freed before that. ccol_for_each() always
destroys its iterator on the way out.

it   Iterator variable that ccol_iter_declare() declares.

Calling it on an iterator that is already NULL is safe and does
nothing. After the call it is NULL, so do not use it again.
 
The macro evaluates it exactly once, and it must be a modifiable lvalue,
such as a variable or an array element.

ccol_iter_declare(3), ccol_iter_next(3), ccol_for_each(3)