core: ringbuffer: reset read and write pointers to 0 when a read buffer consumes all available data

This commit is contained in:
2025-07-30 18:25:17 +01:00
parent 2f874ff11a
commit e4c4de94b8

View File

@@ -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;