mirror of
https://github.com/esphome/esphome.git
synced 2025-04-12 22:00:30 +01:00
[helpers] Allow RAMAllocator to be told the size of the object manually (#8356)
This commit is contained in:
parent
2af5fd5210
commit
0350eafc1e
@ -3,11 +3,11 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
|
||||
#include "esphome/core/optional.h"
|
||||
|
||||
@ -700,8 +700,10 @@ template<class T> class RAMAllocator {
|
||||
}
|
||||
template<class U> constexpr RAMAllocator(const RAMAllocator<U> &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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user