addtition: reset and advance, need testing
This commit is contained in:
@@ -553,3 +553,27 @@ ArrayListErr arrayslice_next(ArraySlice *slice, void *out) {
|
||||
slice->current++;
|
||||
return ARRLIST_OK;
|
||||
}
|
||||
|
||||
ArrayListErr arrayslice_reset(ArraySlice *slice) {
|
||||
if (slice == NULL) {
|
||||
return ARRLIST_NULL_ARG;
|
||||
}
|
||||
|
||||
slice->current = slice->start;
|
||||
|
||||
return ARRLIST_OK;
|
||||
}
|
||||
|
||||
ArrayListErr arrayslice_advance(ArraySlice *slice, size_t n) {
|
||||
if (slice == NULL) {
|
||||
return ARRLIST_NULL_ARG;
|
||||
}
|
||||
|
||||
if (n > SIZE_MAX - slice->current || slice->current + n >= slice->end) {
|
||||
return ARRLIST_OUT_OF_BOUNDS;
|
||||
}
|
||||
|
||||
slice->current += n;
|
||||
|
||||
return ARRLIST_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user