From 6a307ee70fdb79ed871e87dec6ccf2de4a04b371 Mon Sep 17 00:00:00 2001 From: Felipe Neves Date: Fri, 20 Dec 2019 13:03:02 -0300 Subject: [PATCH] heap: removed ptr check in diram area since aligned allocator does not support data allocated from IRAM --- components/heap/heap_caps.c | 8 -------- components/heap/include/esp_heap_caps.h | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/components/heap/heap_caps.c b/components/heap/heap_caps.c index c73264458b..1d73b0087f 100644 --- a/components/heap/heap_caps.c +++ b/components/heap/heap_caps.c @@ -576,14 +576,6 @@ IRAM_ATTR void heap_caps_aligned_free(void *ptr) return; } - if (esp_ptr_in_diram_iram(ptr)) { - //Memory allocated here is actually allocated in the DRAM alias region and - //cannot be de-allocated as usual. dram_alloc_to_iram_addr stores a pointer to - //the equivalent DRAM address, though; free that. - uint32_t *dramAddrPtr = (uint32_t *)ptr; - ptr = (void *)dramAddrPtr[-1]; - } - heap_t *heap = find_containing_heap(ptr); assert(heap != NULL && "free() target pointer is outside heap areas"); multi_heap_aligned_free(heap->heap, ptr); diff --git a/components/heap/include/esp_heap_caps.h b/components/heap/include/esp_heap_caps.h index a0711d0b2d..61db74e1ce 100644 --- a/components/heap/include/esp_heap_caps.h +++ b/components/heap/include/esp_heap_caps.h @@ -96,6 +96,10 @@ void *heap_caps_realloc( void *ptr, size_t size, int caps); * of memory to be returned * * @return A pointer to the memory allocated on success, NULL on failure + * + * @note Any memory allocated with heaps_caps_aligned_alloc() MUST + * be freed with heap_caps_aligned_free() and CANNOT be passed to free() + * */ void *heap_caps_aligned_alloc(size_t alignment, size_t size, int caps); @@ -110,6 +114,9 @@ void *heap_caps_aligned_alloc(size_t alignment, size_t size, int caps); * of memory to be returned * * @return A pointer to the memory allocated on success, NULL on failure + * + * @note Any memory allocated with heap_caps_aligned_calloc() MUST + * be freed with heap_caps_aligned_free() and CANNOT be passed to free() */ void *heap_caps_aligned_calloc(size_t alignment, size_t n, size_t size, uint32_t caps);