61 if (this->
count_ >= API_MAX_SEND_QUEUE)
64 uint16_t buffer_size = total_len - skip;
68 auto *data =
new (std::nothrow) uint8_t[buffer_size];
72 auto *entry =
new (std::nothrow)
Entry{data, buffer_size, 0};
73 if (entry ==
nullptr) {
78 uint16_t to_skip = skip;
79 uint16_t write_pos = 0;
81 for (
int i = 0; i < iovcnt; i++) {
82 if (to_skip >= iov[i].iov_len) {
83 to_skip -=
static_cast<uint16_t
>(iov[i].
iov_len);
85 const uint8_t *
src =
reinterpret_cast<uint8_t *
>(iov[i].
iov_base) + to_skip;
86 uint16_t
len =
static_cast<uint16_t
>(iov[i].
iov_len) - to_skip;
87 std::memcpy(entry->data + write_pos,
src,
len);
95 this->
tail_ = (this->
tail_ + 1) % API_MAX_SEND_QUEUE;
A single heap-allocated send-backlog entry.
uint16_t remaining() const
const uint8_t * current_data() const
static ESPHOME_ALWAYS_INLINE void destroy(Entry *entry)
Free this entry and its data buffer.