ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
esphome::split_buffer::SplitBuffer Class Reference

A SplitBuffer allocates a large memory buffer potentially as multiple smaller buffers to facilitate allocation of large buffers on devices with fragmented memory spaces. More...

#include <split_buffer.h>

Public Member Functions

 SplitBuffer ()=default
 
 ~SplitBuffer ()
 
bool init (size_t total_length)
 
void free ()
 
uint8_t & operator[] (size_t index)
 
const uint8_t & operator[] (size_t index) const
 
void fill (uint8_t value) const
 Fill the entire buffer with a single byte value.
 
size_t size () const
 
size_t get_buffer_count () const
 
bool is_valid () const
 

Detailed Description

A SplitBuffer allocates a large memory buffer potentially as multiple smaller buffers to facilitate allocation of large buffers on devices with fragmented memory spaces.

Each sub-buffer is the same size, except for the last one which may be smaller. Standard array indexing using [] is possible on the buffer, but, since the buffer may not be contiguous in memory, there is no easy way to access the buffer as a single array, i.e. no .data() access like a vector.

Definition at line 14 of file split_buffer.h.

Constructor & Destructor Documentation

◆ SplitBuffer()

esphome::split_buffer::SplitBuffer::SplitBuffer ( )
default

◆ ~SplitBuffer()

esphome::split_buffer::SplitBuffer::~SplitBuffer ( )

Definition at line 9 of file split_buffer.cpp.

Member Function Documentation

◆ fill()

void esphome::split_buffer::SplitBuffer::fill ( uint8_t value) const

Fill the entire buffer with a single byte value.

Parameters
valueFill value

Definition at line 129 of file split_buffer.cpp.

◆ free()

void esphome::split_buffer::SplitBuffer::free ( )

Definition at line 87 of file split_buffer.cpp.

◆ get_buffer_count()

size_t esphome::split_buffer::SplitBuffer::get_buffer_count ( ) const
inline

Definition at line 34 of file split_buffer.h.

◆ init()

bool esphome::split_buffer::SplitBuffer::init ( size_t total_length)

Definition at line 11 of file split_buffer.cpp.

◆ is_valid()

bool esphome::split_buffer::SplitBuffer::is_valid ( ) const
inline

Definition at line 37 of file split_buffer.h.

◆ operator[]() [1/2]

uint8_t & esphome::split_buffer::SplitBuffer::operator[] ( size_t index)

Definition at line 120 of file split_buffer.cpp.

◆ operator[]() [2/2]

const uint8_t & esphome::split_buffer::SplitBuffer::operator[] ( size_t index) const

Definition at line 104 of file split_buffer.cpp.

◆ size()

size_t esphome::split_buffer::SplitBuffer::size ( ) const
inline

Definition at line 31 of file split_buffer.h.


The documentation for this class was generated from the following files: