]> granicus.if.org Git - esp-idf/commitdiff
heap/tests: make IRAM allocation size divisible by 4
authorIvan Grokhotkov <ivan@espressif.com>
Wed, 25 Jul 2018 06:45:39 +0000 (09:45 +0300)
committerIvan Grokhotkov <ivan@espressif.com>
Wed, 25 Jul 2018 06:45:39 +0000 (09:45 +0300)
heap_caps_malloc will fail to poison a block in IRAM with size not
divisible by 4. The proper fix will be to make poisoning code
smarter, or to disallow allocations from IRAM with size not aligned
by 4.

components/heap/test/test_malloc_caps.c

index f1db712b7a257f5b7d7621e218b51b873bc96fe0..950f18455c537e88dd082b0550583193b2dc77f7 100644 (file)
@@ -43,7 +43,7 @@ TEST_CASE("Capabilities allocator test", "[heap]")
     //the following gives size of IRAM-only (not D/IRAM) memory.
     size_t free_iram = heap_caps_get_free_size(MALLOC_CAP_INTERNAL) -
                            heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
-    size_t alloc32 = MIN(free_iram / 2, 10*1024);
+    size_t alloc32 = MIN(free_iram / 2, 10*1024) & (~3);
     printf("Freeing; allocating %u bytes of 32K-capable RAM\n", alloc32);
     m1 = heap_caps_malloc(alloc32, MALLOC_CAP_32BIT);
     printf("--> %p\n", m1);