/* * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ /* Generic test for malloc/free */ #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" #include "freertos/queue.h" #include "unity.h" #include "esp_heap_caps.h" #include "sdkconfig.h" static int **allocatedMem; static int noAllocated; static int tryAllocMem(void) { int i, j; const int allocateMaxK=1024*5; //try to allocate a max of 5MiB allocatedMem=malloc(sizeof(int *)*allocateMaxK); if (!allocatedMem) return 0; for (i=0; i 1024) TEST_CASE("Check if reserved DMA pool still can allocate even when malloc()'ed memory is exhausted", "[heap]") { char** dmaMem=malloc(sizeof(char*)*512); assert(dmaMem); int m=tryAllocMem(); int i=0; for (i=0; i<512; i++) { dmaMem[i]=heap_caps_malloc(1024, MALLOC_CAP_DMA); if (dmaMem[i]==NULL) break; } for (int j=0; j