|
From: Raphael K. da C. <ra...@Fr...> - 2012-07-03 04:18:15
|
Cedric BAIL <ced...@fr...> writes:
>>>> - *_foreach():
>>>> One could argue that passing NULL should be equivalent to an empty
>>>> loop. For example, right now
>>>> eina_iterator_foreach(NULL, ..., ...)
>>>> generates a magic check error message, while
>>>> EINA_ITERATOR_FOREACH(NULL, ...)
>>>> does not.
>
> There is valid use case for when an iterator could be NULL. If you do :
> it = eina_file_stat_ls("/plop");
> EINA_ITERATOR_FOREACH(it, ...)
> {
> ....
> }
> eina_iterator_free(it);
>
> It cleary simplify the code in my opinion without impacting speed at
> all if we do handle it == NULL case. So for this one I would like to
> have it handle.
That's exactly what caused me to look into this :-) I've changed
eina_iterator_foreach() so that it just returns early without
complaining if a NULL iterator is passed to it, so both
eina_iterator_free() and EINA_ITERATOR_FREE() should have a more similar
behavior now.
|