ring
1.1
A Flexible Ring Buffer in C.
|
Implementation of a ring buffer in C. More...
#include <stdint.h>
Data Structures | |
struct | ring_t |
Struct for ring buffer. More... | |
Functions | |
static ring_t * | ringCreate (unsigned int tsize, unsigned int size) |
Create ring struct and buffer. More... | |
static void | ringFree (ring_t *r) |
Free ring struct and buffer. More... | |
static unsigned int | ringGetCount (ring_t *r) |
Get number of used elements in ring buffer. More... | |
static unsigned int | ringGetFreeCount (ring_t *r) |
Get number of free elements in ring buffer. More... | |
static int | ringIsEmpty (ring_t *r) |
Check if ring buffer is empty. More... | |
static int | ringIsFull (ring_t *r) |
Check if ring buffer is full. More... | |
static unsigned int | ringWrite (ring_t *r, uint8_t *pData) |
Write one element to ring buffer. More... | |
static uint8_t * | ringRead (ring_t *r, uint8_t *pData) |
Read one element from ring buffer. More... | |
static uint8_t * | ringPeek (ring_t *r, uint8_t *pData) |
Peek next element of the ring buffer Read next element but keep this element in the ring buffer. More... | |
static uint8_t * | ringSearchToken (ring_t *r, uint8_t token) |
Search one byte (element) in ring buffer. More... | |
static uint8_t * | ringGetLine (ring_t *r, uint8_t *pLine) |
Get a complete line from the ring buffer. More... | |
static void | ringPrintInfo (ring_t *r) |
Print information to stdout about the ring buffer. More... | |
static void | ringPrintBuffer (ring_t *r) |
Print the content in the ring buffer to stdout. More... | |
Implementation of a ring buffer in C.
The compleet ring buffer is descripted in this header file. There is no accompanying c file. This ring buffer uses a struct with information about the ring buffer. The ring buffer can contain elements of any size. Multiple ring buffers can be used in the same project.
|
inlinestatic |
Create ring struct and buffer.
[in] | tsize | datatype size of elements in ring buffer |
[in] | size | total number of elements in ring buffer |
|
inlinestatic |
Free ring struct and buffer.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Get number of used elements in ring buffer.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Get number of free elements in ring buffer.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Get a complete line from the ring buffer.
[in] | r | Pointer to ring structure |
[out] | pLine | Pointer to a line buffer where data must be written to |
|
inlinestatic |
Check if ring buffer is empty.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Check if ring buffer is full.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Peek next element of the ring buffer Read next element but keep this element in the ring buffer.
[in] | r | Pointer to ring structure |
[out] | pData | Pointer to location where element must be written |
|
inlinestatic |
Print the content in the ring buffer to stdout.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Print information to stdout about the ring buffer.
[in] | r | Pointer to ring structure |
|
inlinestatic |
Read one element from ring buffer.
[in] | r | Pointer to ring structure |
[in] | pData | Pointer to location where value of element must be written |
|
inlinestatic |
Search one byte (element) in ring buffer.
[in] | r | Pointer to ring structure |
[in] | token | Token to be searched |
|
inlinestatic |
Write one element to ring buffer.
[in] | r | Pointer to ring structure |
[out] | pData | Pointer to element to be written |