Changed Ringbuf API: Ringbuf_Pop_Front is now Ringbuf_Pop, and now it copies the buffer into parameter and returns boolean. Original method was not safe since it returned a pointer to the element but freed the buffer element. Changed Ringbuf_Get_Front to Ringbuf_Peek with no change in functionality, to make names more consistent.
Updated all the MS/TP datalink layer implementations that use Ringbuf library.
This commit is contained in:
@@ -49,13 +49,17 @@ extern "C" {
|
||||
RING_BUFFER const *b);
|
||||
bool Ringbuf_Empty(
|
||||
RING_BUFFER const *b);
|
||||
volatile uint8_t *Ringbuf_Get_Front(
|
||||
volatile uint8_t *Ringbuf_Peek(
|
||||
RING_BUFFER const *b);
|
||||
volatile uint8_t *Ringbuf_Pop_Front(
|
||||
RING_BUFFER * b);
|
||||
bool Ringbuf_Pop(
|
||||
RING_BUFFER * b,
|
||||
uint8_t *data_element);
|
||||
bool Ringbuf_Put(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
volatile uint8_t * data_element); /* one element to add to the ring */
|
||||
uint8_t *data_element); /* one element to add to the ring */
|
||||
bool Ringbuf_Put_Front(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
uint8_t *data_element);
|
||||
volatile uint8_t *Ringbuf_Alloc(
|
||||
RING_BUFFER * b);
|
||||
/* Note: element_count must be a power of two */
|
||||
@@ -65,6 +69,14 @@ extern "C" {
|
||||
unsigned element_size, /* size of one element in the data block */
|
||||
unsigned element_count); /* number of elements in the data block */
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
void testRingBufSize16(
|
||||
Test * pTest);
|
||||
void testRingBufSize32(
|
||||
Test * pTest);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in New Issue
Block a user