Loading...
Searching...
No Matches
chunked_ringbuffer.h File Reference

Chunked Ringbuffer. More...

Detailed Description

Chunked Ringbuffer.

A chunked ringbuffer is a ringbuffer that holds chunks of data.

Author
Benjamin Valentin benja.nosp@m.min..nosp@m.valen.nosp@m.tin@.nosp@m.ml-pa.nosp@m..com

Definition in file chunked_ringbuffer.h.

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
+ Include dependency graph for chunked_ringbuffer.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  chunk_ringbuf_t
 A chunked ringbuffer. More...
 

Macros

#define CONFIG_CHUNK_NUM_MAX   (4)
 The maximum number of chunks that can be stored in a Chunked Ringbuffer.
 

Typedefs

typedef void(* crb_foreach_callback_t) (void *ctx, uint8_t *bytes, size_t len)
 Callback function for crb_chunk_foreach.
 

Functions

void crb_init (chunk_ringbuf_t *rb, void *buffer, size_t len)
 Initialize a Chunked Ringbuffer.
 
static bool crb_start_chunk (chunk_ringbuf_t *rb)
 Start a new chunk on the ringbuffer.
 
static bool crb_add_byte (chunk_ringbuf_t *rb, uint8_t b)
 Insert a byte into the current chunk.
 
bool crb_add_bytes (chunk_ringbuf_t *rb, const void *data, size_t len)
 Insert a number of bytes into the current chunk.
 
bool crb_end_chunk (chunk_ringbuf_t *rb, bool valid)
 Close the current chunk.
 
bool crb_add_chunk (chunk_ringbuf_t *rb, const void *data, size_t len)
 Add a complete chunk to the Ringbuffer.
 
bool crb_get_chunk_size (chunk_ringbuf_t *rb, size_t *len)
 Get the size of the first valid chunk.
 
bool crb_peek_bytes (chunk_ringbuf_t *rb, void *dst, size_t offset, size_t len)
 Get a number of bytes from the first valid chunk without consuming it.
 
bool crb_consume_chunk (chunk_ringbuf_t *rb, void *dst, size_t len)
 Remove a chunk from the valid chunk array.
 
bool crb_chunk_foreach (chunk_ringbuf_t *rb, crb_foreach_callback_t func, void *ctx)
 Execute a callback for each byte in the first valid chunk The callback function may be called twice if the chunk is non-continuous.