31 [[nodiscard]]
inline bool reserve(
size_t n) ESPHOME_ALWAYS_INLINE {
return n <= this->
capacity_ || this->
grow_(n); }
37 [[nodiscard]]
inline bool reserve_and_resize(
size_t reserve_size,
size_t new_size) ESPHOME_ALWAYS_INLINE {
38 if (!this->
reserve(std::max(reserve_size, new_size)))
40 this->
size_ =
static_cast<uint16_t
>(new_size);
44 [[nodiscard]] uint8_t *
append(
size_t n);
47#ifdef ESPHOME_DEBUG_API
51 std::memmove(this->
data_.get(), this->data_.get() + drop, this->size_);
54 const uint8_t *
data()
const {
return this->
data_.get(); }
69#ifdef ESPHOME_DEBUG_API
Byte buffer that skips zero-initialization on resize().
void drop_front(size_t drop)
Drop the first drop bytes, sliding the rest down. Precondition: drop <= size().
const uint8_t * data() const
void release()
Release all memory (equivalent to std::vector swap trick).
const uint8_t & operator[](size_t i) const
uint8_t * append(size_t n)
Grow by n bytes; returns the new bytes, or nullptr on allocation failure.
RAMUniquePtr< uint8_t[]> data_
uint8_t & operator[](size_t i)
bool reserve(size_t n) ESPHOME_ALWAYS_INLINE
Returns false if allocation fails; the buffer is left unchanged.
bool resize(size_t n) ESPHOME_ALWAYS_INLINE
Returns false if allocation fails; the buffer is left unchanged. No zero-fill.
bool reserve_and_resize(size_t reserve_size, size_t new_size) ESPHOME_ALWAYS_INLINE
Reserve capacity for max(reserve_size, new_size) bytes, then set size to new_size.
void debug_check_drop_(size_t drop) const
static constexpr size_t MAX_SIZE
std::unique_ptr< T, RAMDeleter< T > > RAMUniquePtr
unique_ptr over RAMAllocator storage