Description
Implement a fixed-size circular (ring) buffer — a FIFO data structure where write and read positions wrap around, avoiding memory allocation after initialization.
typedef struct {
bytes_t data;
unsigned int cap;
unsigned int head;
unsigned int tail;
unsigned int len;
} CircularBuffer;
Use cases
- Serial/UART communication
- Audio streaming
- Log ring buffers
- Embedded systems with no heap
References
Description
Implement a fixed-size circular (ring) buffer — a FIFO data structure where write and read positions wrap around, avoiding memory allocation after initialization.
Use cases
References
pipe, Linux kernelkfifo, and audio APIs (JACK, ALSA)