Skip to content

Implement Circular Buffer (Ring Buffer) #32

@davidgaspardev

Description

@davidgaspardev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions