diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 82b0fe07f8..3f371cd829 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -3,11 +3,11 @@ #include #include #include +#include #include #include #include #include -#include #include "esphome/core/optional.h" @@ -700,8 +700,10 @@ template class RAMAllocator { } template constexpr RAMAllocator(const RAMAllocator &other) : flags_{other.flags_} {} - T *allocate(size_t n) { - size_t size = n * sizeof(T); + T *allocate(size_t n) { return this->allocate(n, sizeof(T)); } + + T *allocate(size_t n, size_t manual_size) { + size_t size = n * manual_size; T *ptr = nullptr; #ifdef USE_ESP32 if (this->flags_ & Flags::ALLOC_EXTERNAL) {