38 memcpy(buf, start, msg_len);
41 size_t len2 = len - len1;
42 memcpy(buf, start, len1);
43 memcpy(buf + len1, cb->
_buf, len2);
46 int nb_bytes = msg_len;
64 if ((
int)len >= available) {
78 size_t len2 = len - len1;
80 memcpy(cb->
_buf, buf + len1, len2);
void circular_buffer_init(struct circular_buffer *cb, uint8_t *buffer, size_t len)
initialize a circular buffer.
int circular_buffer_put(struct circular_buffer *cb, uint8_t *buf, size_t len)
Copy buf in the circular buffer.
int circular_buffer_get(struct circular_buffer *cb, uint8_t *buf, size_t len)
copy the next buffer available in cb to buf.
@ CIR_ERROR_NO_MSG
circular buffer is empty
@ CIR_ERROR_NO_SPACE_AVAILABLE
no space available in the circular buffer
@ CIR_ERROR_BUFFER_TOO_SMALL
destination buffer is too small
This is a general purpose circular buffer for storing buffers in a FIFO order.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.