mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	[helpers] Allow RAMAllocator to be told the size of the object manually (#8356)
This commit is contained in:
		@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user