30 [[nodiscard]]
inline bool reserve(
size_t n) ESPHOME_ALWAYS_INLINE {
return n <= this->
capacity_ || this->
grow_(n); }
36 [[nodiscard]]
inline bool reserve_and_resize(
size_t reserve_size,
size_t new_size) ESPHOME_ALWAYS_INLINE {
37 if (!this->
reserve(std::max(reserve_size, new_size)))
39 this->
size_ = new_size;
43 const uint8_t *
data()
const {
return this->
data_.get(); }
58 std::unique_ptr<uint8_t[]>
data_;
Byte buffer that skips zero-initialization on resize().
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 & operator[](size_t i)
bool reserve(size_t n) ESPHOME_ALWAYS_INLINE
Returns false if allocation fails; the buffer is left unchanged.
std::unique_ptr< uint8_t[]> data_
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.