improve ringbuffer

This commit is contained in:
xianjimli 2020-09-04 07:03:00 +08:00
parent 24a1976eb4
commit f479ff3dd1
2 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
* 2020/09/04
* 完善ringbuffer(感谢网友J,提供补丁)
* 2020/09/03
* 完善toast感谢智明提供补丁
* 完善calibration win感谢俊杰提供补丁

View File

@ -233,6 +233,7 @@ ret_t ring_buffer_read_len(ring_buffer_t* ring_buffer, void* buff, uint32_t size
return_value_if_fail(ring_buffer != NULL && buff != NULL, RET_BAD_PARAMS);
if (ring_buffer_size(ring_buffer) >= size) {
ring_buffer->full = FALSE;
return ring_buffer_read(ring_buffer, buff, size) == size ? RET_OK : RET_FAIL;
} else {
return RET_FAIL;
@ -243,6 +244,7 @@ ret_t ring_buffer_skip(ring_buffer_t* ring_buffer, uint32_t size) {
return_value_if_fail(ring_buffer != NULL, RET_BAD_PARAMS);
if (ring_buffer_size(ring_buffer) >= size) {
ring_buffer->full = FALSE;
ring_buffer->r = (ring_buffer->r + size) % ring_buffer->capacity;
return RET_OK;