Closed yaoture3 closed 1 year ago
Issue repro steps:
Add at least 2 elements with deque_add_first.
Use deque_remove_at to get a element which index greater than 0,your will find element is wrong.
I think the problem is at this sentence 'void *removed = deque->buffer[index];', in which 'index' should be replaced by 'p'.
enum cc_stat deque_remove_at(Deque *deque, size_t index, void **out) { if (index >= deque->size) return CC_ERR_OUT_OF_RANGE;
const size_t c = deque->capacity - 1; const size_t l = deque->last & c; const size_t f = deque->first & c; const size_t p = (deque->first + index) & c; void *removed = deque->buffer[index]; if (index == 0)
......
Issue repro steps:
Add at least 2 elements with deque_add_first.
Use deque_remove_at to get a element which index greater than 0,your will find element is wrong.
I think the problem is at this sentence 'void *removed = deque->buffer[index];', in which 'index' should be replaced by 'p'.
enum cc_stat deque_remove_at(Deque *deque, size_t index, void **out) { if (index >= deque->size) return CC_ERR_OUT_OF_RANGE;
......