Closed daipingh closed 2 hours ago
Describe the bug When I iterate over yyjson_mut_arr through yyjson_mut_arr_iter, the number of data actually processed is 1 less than expected.
yyjson_mut_arr
yyjson_mut_arr_iter
Then I looked at the code of yyjson_mut_arr_iter_next() and found that it seemed inconsistent with the implementation of yyjson_arr_iter_next().
yyjson_mut_arr_iter_next()
yyjson_arr_iter_next() returns the element before the iteration, while yyjson_mut_arr_iter_next() seems to return the element after the iteration.
yyjson_api_inline yyjson_val *yyjson_arr_iter_next(yyjson_arr_iter *iter) { yyjson_val *val; if (iter && iter->idx < iter->max) { val = iter->cur; iter->cur = unsafe_yyjson_get_next(val); iter->idx++; return val; } return NULL; } yyjson_api_inline yyjson_mut_val *yyjson_mut_arr_iter_next( yyjson_mut_arr_iter *iter) { if (iter && iter->idx < iter->max) { yyjson_mut_val *val = iter->cur; iter->pre = val; iter->cur = val->next; iter->idx++; return iter->cur; } return NULL; }
I'm not sure if this is the cause of my problem.
Your environment
Additional context Add any other context about the problem here.
Sorry, there is no problem with yyjson. This problem is caused by other code problems. This issue will be closed
Describe the bug When I iterate over
yyjson_mut_arr
throughyyjson_mut_arr_iter
, the number of data actually processed is 1 less than expected.Then I looked at the code of
yyjson_mut_arr_iter_next()
and found that it seemed inconsistent with the implementation of yyjson_arr_iter_next().yyjson_arr_iter_next() returns the element before the iteration, while yyjson_mut_arr_iter_next() seems to return the element after the iteration.
I'm not sure if this is the cause of my problem.
Your environment
Additional context Add any other context about the problem here.