Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CC_ITER_END vs CC_ERR_OUT_OF_RANGE #61

Closed
f2404 opened this issue Apr 27, 2016 · 2 comments
Closed

CC_ITER_END vs CC_ERR_OUT_OF_RANGE #61

f2404 opened this issue Apr 27, 2016 · 2 comments

Comments

@f2404
Copy link
Contributor

f2404 commented Apr 27, 2016

Different statuses are returned in the same situation - when iterator reaches end of array:

 * @return CC_OK if a next element pair is returned, or CC_ITER_END if the end of one
 * of the arrays has been reached.
 */
enum cc_stat array_zip_iter_next(ArrayZipIter *iter, void **out1, void **out2)
 * @return CC_OK if the element was successfully removed, or CC_ERR_OUT_OF_RANGE.
 */
enum cc_stat array_zip_iter_remove(ArrayZipIter *iter, void **out1, void **out2)

Which status should be used to be consistent? I'd suggest using CC_ITER_END whenever an iterator is involved.

@f2404
Copy link
Contributor Author

f2404 commented May 4, 2016

@srdja ?

@srdja
Copy link
Owner

srdja commented Jun 29, 2016

The problem was that the behaviors of array_*_iter_remove and deque_*_iter_remove functions were kind of inconsistent with their list and slist equivalents, in that you could call iter_remove repeatedly until you've exausted the array, and thus possibly running into an CC_ERR_OUT_OF_RANGE, which is not the case with list equivalents where you can only call iter_remove once after calling iter_next. Basically array_iter_remove was allowing you to 'jump ahead' of the iterator which is not something that should ever happen.

I've added a fix for this. It should be more sensible now :-)

@srdja srdja closed this as completed Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants