|
ESPHome 2026.3.0-dev
|
Small buffer optimization - stores data inline when small, heap-allocates for large data This avoids heap fragmentation for common small allocations while supporting arbitrary sizes. More...
#include <helpers.h>
Public Member Functions | |
| SmallInlineBuffer ()=default | |
| ~SmallInlineBuffer () | |
| SmallInlineBuffer (SmallInlineBuffer &&other) noexcept | |
| SmallInlineBuffer & | operator= (SmallInlineBuffer &&other) noexcept |
| SmallInlineBuffer (const SmallInlineBuffer &)=delete | |
| SmallInlineBuffer & | operator= (const SmallInlineBuffer &)=delete |
| void | set (const uint8_t *src, size_t size) |
| Set buffer contents, allocating heap if needed. | |
| uint8_t * | data () |
| const uint8_t * | data () const |
| size_t | size () const |
Protected Member Functions | |
| bool | is_inline_ () const |
Protected Attributes | ||
| size_t | len_ {0} | |
| union { | ||
| uint8_t inline_ [InlineSize] {} | ||
| uint8_t * heap_ | ||
| }; | ||
Small buffer optimization - stores data inline when small, heap-allocates for large data This avoids heap fragmentation for common small allocations while supporting arbitrary sizes.
Memory management is encapsulated - callers just use set() and data().
|
default |
|
inline |
|
inlinenoexcept |
|
delete |
|
inline |
|
inline |
|
inlineprotected |
|
delete |
|
inlinenoexcept |
|
inline |
|
inline |
| union { ... } esphome::SmallInlineBuffer< InlineSize > |
| uint8_t* esphome::SmallInlineBuffer< InlineSize >::heap_ |
| uint8_t esphome::SmallInlineBuffer< InlineSize >::inline_[InlineSize] {} |
|
protected |