mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-10-20 13:55:26 +08:00
ringbuffer: fix the ambiguous name
RT_RINGBUFFER_SIZE could mean "the size of the whole buffer", "the size of the empty space" or "the size of the data". Moreover, it's never a micro anymore. Change it to rt_ringbuffer_data_len before it's too late. Also, RT_RINGBUFFER_EMPTY is changed to rt_ringbuffer_space_len.
This commit is contained in:
@@ -53,7 +53,7 @@ rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb,
|
||||
RT_ASSERT(rb != RT_NULL);
|
||||
|
||||
/* whether has enough space */
|
||||
size = RT_RINGBUFFER_EMPTY(rb);
|
||||
size = rt_ringbuffer_space_len(rb);
|
||||
|
||||
/* no space */
|
||||
if (size == 0)
|
||||
@@ -100,7 +100,7 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
|
||||
RT_ASSERT(rb != RT_NULL);
|
||||
|
||||
/* whether has enough data */
|
||||
size = RT_RINGBUFFER_SIZE(rb);
|
||||
size = rt_ringbuffer_data_len(rb);
|
||||
|
||||
/* no data */
|
||||
if (size == 0)
|
||||
@@ -143,7 +143,7 @@ rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
|
||||
RT_ASSERT(rb != RT_NULL);
|
||||
|
||||
/* whether has enough space */
|
||||
if (!RT_RINGBUFFER_EMPTY(rb))
|
||||
if (!rt_ringbuffer_space_len(rb))
|
||||
return 0;
|
||||
|
||||
rb->buffer_ptr[rb->write_index] = ch;
|
||||
@@ -171,7 +171,7 @@ rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch)
|
||||
RT_ASSERT(rb != RT_NULL);
|
||||
|
||||
/* ringbuffer is empty */
|
||||
if (!RT_RINGBUFFER_SIZE(rb))
|
||||
if (!rt_ringbuffer_data_len(rb))
|
||||
return 0;
|
||||
|
||||
/* put character */
|
||||
|
Reference in New Issue
Block a user