Heap: fix free bytes calculation for TLSF heap

* Closes https://github.com/espressif/esp-idf/issues/8270
This commit is contained in:
Omar Chebib
2022-03-03 13:01:54 +08:00
parent 8f67af174e
commit 4ce4c5a68a
3 changed files with 34 additions and 3 deletions

View File

@@ -122,8 +122,10 @@ TEST_CASE("IRAM_8BIT capability test", "[heap]")
TEST_ASSERT((((int)ptr)&0xFF000000)==0x40000000);
TEST_ASSERT(heap_caps_get_free_size(MALLOC_CAP_IRAM_8BIT) == (free_size - heap_caps_get_allocated_size(ptr)));
TEST_ASSERT(heap_caps_get_free_size(MALLOC_CAP_32BIT) == (free_size32 - heap_caps_get_allocated_size(ptr)));
/* As the heap allocator may present an overhead for allocated blocks,
* we need to check that the free heap size is now smaller than former free size. */
TEST_ASSERT(heap_caps_get_free_size(MALLOC_CAP_IRAM_8BIT) <= (free_size - heap_caps_get_allocated_size(ptr)));
TEST_ASSERT(heap_caps_get_free_size(MALLOC_CAP_32BIT) <= (free_size32 - heap_caps_get_allocated_size(ptr)));
free(ptr);
}