hat-util
0.6.16
Utility library
|
Data buffer. More...
#include <stdint.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | hat_buff_t |
Data buffer. More... | |
Macros | |
#define | HAT_BUFF_SUCCESS 0 |
#define | HAT_BUFF_ERROR (-1) |
Functions | |
static size_t | hat_buff_available (hat_buff_t *buff) |
Available capacity. More... | |
static int | hat_buff_write (hat_buff_t *buff, uint8_t *data, size_t data_len) |
Write data to buffer. More... | |
static uint8_t * | hat_buff_read (hat_buff_t *buff, size_t size) |
Read data from buffer. More... | |
Data buffer.
Data buffer is simple byte storage with associated size (capacity) and position pointer.
If used as data source, position points to location which is not yet consumed.
If used as data storage, position points to location where next byte should be stored.
#define HAT_BUFF_ERROR (-1) |
#define HAT_BUFF_SUCCESS 0 |
|
inlinestatic |
Available capacity.
[in] | buff | buffer instance |
Returns difference between size and current position or 0
if current position is greater or equal to size.
|
inlinestatic |
Read data from buffer.
[in] | buff | buffer instance |
[in] | size | data size |
Returned data pointer points to buffered data starting from current position. If buffer available capacity is smaller than requested size, NULL
is returned. Position is incremented if data is successfully read.
|
inlinestatic |
Write data to buffer.
[in] | buff | buffer instance |
[in] | data | data |
[in] | data_len | data length |
HAT_BUFF_SUCCESS
or HAT_BUFF_ERROR
Data is written to buffer starting from current position. Position is incremented if data is successfully written.