ESPHome
2026.9.0-dev
Loading...
Searching...
No Matches
esphome
components
api
api_buffer.cpp
Go to the documentation of this file.
1
#include "
api_buffer.h
"
2
#include <new>
3
4
namespace
esphome::api
{
5
6
bool
APIBuffer::grow_
(
size_t
n) {
7
// nothrow (no zero-fill) so OOM is reportable; plain new aborts instead
8
// (NEW_OOM_ABORT on ESP8266 Arduino, exception stub on ESP-IDF).
9
// RAMAllocator is no fit here: unique_ptr needs delete[]-compatible memory.
10
std::unique_ptr<uint8_t[]>
new_data
(
new
(std::nothrow) uint8_t[n]);
11
if
(
new_data
==
nullptr
)
12
return
false
;
13
if
(this->
size_
)
14
std::memcpy(
new_data
.get(), this->data_.get(), this->size_);
15
this->
data_
= std::move(
new_data
);
16
this->
capacity_
= n;
17
return
true
;
18
}
19
20
}
// namespace esphome::api
api_buffer.h
esphome::api::APIBuffer::capacity_
size_t capacity_
Definition
api_buffer.h:60
esphome::api::APIBuffer::grow_
bool grow_(size_t n)
Definition
api_buffer.cpp:6
esphome::api::APIBuffer::size_
size_t size_
Definition
api_buffer.h:59
esphome::api::APIBuffer::data_
std::unique_ptr< uint8_t[]> data_
Definition
api_buffer.h:58
esphome::api
Definition
api_buffer.cpp:4
esphome::new_data
auto * new_data
Definition
helpers.cpp:29
Generated by
1.12.0