#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
Go to the source code of this file.
§ RingBuf_Object
§ RingBuf_Handle
§ RingBuf_construct()
void RingBuf_construct |
( |
RingBuf_Handle |
object, |
|
|
unsigned char * |
bufPtr, |
|
|
size_t |
bufSize |
|
) |
| |
Initialize circular buffer.
- Parameters
-
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
bufPtr | Pointer to data buffer to be used for the circular buffer. The buffer is NOT stored in RingBuf_Object. |
bufSize | The size of bufPtr in number of unsigned chars. |
§ RingBuf_get()
Get an unsigned char from the end of the circular buffer and remove it.
- Parameters
-
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Pointer to an unsigned char to be filled with the data from the front of the circular buffer. |
- Returns
- Number of unsigned chars on the buffer after taking it out of the circular buffer. If it returns -1, the circular buffer was already empty and data is invalid.
§ RingBuf_getCount()
Get the number of unsigned chars currently stored on the circular buffer.
- Parameters
-
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
- Returns
- Number of unsigned chars on the circular buffer.
§ RingBuf_isFull()
Function to determine if the circular buffer is full or not.
- Parameters
-
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
- Returns
- true if circular buffer is full, else false.
§ RingBuf_getMaxCount()
A high-water mark indicating the largest number of unsigned chars stored on the circular buffer since it was constructed.
- Returns
- Get the largest number of unsigned chars that were at one point in the circular buffer.
§ RingBuf_peek()
Get an unsigned char from the end of the circular buffer without removing it.
- Parameters
-
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Pointer to an unsigned char to be filled with the data from the front of the circular buffer. This function does not remove the data from the circular buffer. Do not evaluate data if the count returned is equal to 0. |
- Returns
- Number of unsigned chars on the circular buffer. If the number != 0, then data will contain the unsigned char at the end of the circular buffer.
§ RingBuf_put()
Put an unsigned char into the end of the circular buffer.
- Parameters
-
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | unsigned char to be placed at the end of the circular buffer. |
- Returns
- Number of unsigned chars on the buffer after it was added, or -1 if it's already full.