forked from espressif/esp-idf
freertos(IDF): Remove usage of xPortGetFreeHeapSize() outside FreeRTOS
After heap_idf.c has been added (where the FreeRTOS heap is a subset of the ESP-IDF heap), xPortGetFreeHeapSize() was updated to only returns the free size of the FreeRTOS heap and not the entire ESP-IDF heap. This commit replaces calls of xPortGetFreeHeapSize() with esp_get_free_heap_size() in places outside of FreeRTOS.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "unity.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@@ -127,7 +128,7 @@ TEST_CASE("unreasonable allocs should all fail", "[heap]")
|
||||
TEST_ASSERT_NULL(test_malloc_wrapper(16*1024*1024));
|
||||
TEST_ASSERT_NULL(test_malloc_wrapper(SIZE_MAX / 2));
|
||||
TEST_ASSERT_NULL(test_malloc_wrapper(SIZE_MAX - 256));
|
||||
TEST_ASSERT_NULL(test_malloc_wrapper(xPortGetFreeHeapSize() - 1));
|
||||
TEST_ASSERT_NULL(test_malloc_wrapper(esp_get_free_heap_size() - 1));
|
||||
}
|
||||
|
||||
TEST_CASE("malloc(0) should return a NULL pointer", "[heap]")
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "esp_private/esp_clk.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_cpu.h"
|
||||
#include "esp_system.h"
|
||||
#include "spi_flash_mmap.h"
|
||||
|
||||
|
||||
@@ -43,10 +44,10 @@ TEST(wear_levelling, wl_unmount_doesnt_leak_memory)
|
||||
wl_unmount(handle);
|
||||
|
||||
// test that we didn't leak any memory on the next init/deinit
|
||||
size_t size_before = xPortGetFreeHeapSize();
|
||||
size_t size_before = esp_get_free_heap_size();
|
||||
TEST_ESP_OK(wl_mount(partition, &handle));
|
||||
wl_unmount(handle);
|
||||
size_t size_after = xPortGetFreeHeapSize();
|
||||
size_t size_after = esp_get_free_heap_size();
|
||||
|
||||
TEST_ASSERT_EQUAL(size_before, size_after);
|
||||
}
|
||||
@@ -64,21 +65,21 @@ TEST(wear_levelling, wl_mount_checks_partition_params)
|
||||
// test small partition: result should be error
|
||||
for (int i = 0; i < 5; i++) {
|
||||
fake_partition.size = SPI_FLASH_SEC_SIZE * (i);
|
||||
size_before = xPortGetFreeHeapSize();
|
||||
size_before = esp_get_free_heap_size();
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, wl_mount(&fake_partition, &handle));
|
||||
// test that we didn't leak any memory
|
||||
size_after = xPortGetFreeHeapSize();
|
||||
size_after = esp_get_free_heap_size();
|
||||
TEST_ASSERT_EQUAL_HEX32(size_before, size_after);
|
||||
}
|
||||
|
||||
// test minimum size partition: result should be OK
|
||||
fake_partition.size = SPI_FLASH_SEC_SIZE * 5;
|
||||
size_before = xPortGetFreeHeapSize();
|
||||
size_before = esp_get_free_heap_size();
|
||||
TEST_ESP_OK(wl_mount(&fake_partition, &handle));
|
||||
wl_unmount(handle);
|
||||
|
||||
// test that we didn't leak any memory
|
||||
size_after = xPortGetFreeHeapSize();
|
||||
size_after = esp_get_free_heap_size();
|
||||
TEST_ASSERT_EQUAL_HEX32(size_before, size_after);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user