|
ESPHome 2026.11.0-dev
|
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, size_t max_buffer_size=SIZE_MAX) |
| 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. | |
| const uint8_t * | get_span (size_t index, size_t &length) const |
| uint8_t * | get_span (size_t index, size_t &length) |
| void | write (size_t index, const uint8_t *data, size_t length) |
| size_t | size () const |
| size_t | get_buffer_count () const |
| bool | is_valid () const |
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.
|
default |
| esphome::split_buffer::SplitBuffer::~SplitBuffer | ( | ) |
Definition at line 12 of file split_buffer.cpp.
| void esphome::split_buffer::SplitBuffer::fill | ( | uint8_t | value | ) | const |
Fill the entire buffer with a single byte value.
| value | Fill value |
Definition at line 160 of file split_buffer.cpp.
| void esphome::split_buffer::SplitBuffer::free | ( | ) |
Definition at line 90 of file split_buffer.cpp.
|
inline |
Definition at line 41 of file split_buffer.h.
| uint8_t * esphome::split_buffer::SplitBuffer::get_span | ( | size_t | index, |
| size_t & | length ) |
Definition at line 138 of file split_buffer.cpp.
| const uint8_t * esphome::split_buffer::SplitBuffer::get_span | ( | size_t | index, |
| size_t & | length ) const |
Definition at line 128 of file split_buffer.cpp.
| bool esphome::split_buffer::SplitBuffer::init | ( | size_t | total_length, |
| size_t | max_buffer_size = SIZE_MAX ) |
Definition at line 14 of file split_buffer.cpp.
|
inline |
Definition at line 44 of file split_buffer.h.
| uint8_t & esphome::split_buffer::SplitBuffer::operator[] | ( | size_t | index | ) |
Definition at line 123 of file split_buffer.cpp.
| const uint8_t & esphome::split_buffer::SplitBuffer::operator[] | ( | size_t | index | ) | const |
Definition at line 107 of file split_buffer.cpp.
|
inline |
Definition at line 38 of file split_buffer.h.
| void esphome::split_buffer::SplitBuffer::write | ( | size_t | index, |
| const uint8_t * | data, | ||
| size_t | length ) |
Definition at line 142 of file split_buffer.cpp.