core: ringbuffer: reset read and write pointers to 0 when a read buffer consumes all available data
This commit is contained in:
@@ -289,6 +289,14 @@ enum b_status b_ringbuffer_close_read_buffer(
|
||||
buf->r_read_ptr = 0;
|
||||
}
|
||||
|
||||
if (buf->r_read_ptr == buf->r_write_ptr) {
|
||||
/* the ringbuffer is now empty. set both pointers to 0.
|
||||
* this ensures that the whole buffer will be available
|
||||
* contiguously to the next call to open_write_buffer */
|
||||
buf->r_read_ptr = 0;
|
||||
buf->r_write_ptr = 0;
|
||||
}
|
||||
|
||||
buf->r_opened_buf = NULL;
|
||||
buf->r_opened_capacity = 0;
|
||||
buf->r_flags &= ~B_RINGBUFFER_READ_LOCKED;
|
||||
|
||||
Reference in New Issue
Block a user