Merge branch 'matter_realloc' into 'main'

Added esp_matter_mem_realloc API

See merge request app-frameworks/esp-matter!412
This commit is contained in:
Hrishikesh Dhayagude
2023-07-11 13:22:13 +08:00
2 changed files with 21 additions and 2 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
// Copyright 2023 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -29,6 +29,19 @@ IRAM_ATTR void *esp_matter_mem_calloc(size_t n, size_t size)
#endif
}
IRAM_ATTR void *esp_matter_mem_realloc(void *ptr, size_t size)
{
#if CONFIG_ESP_MATTER_MEM_ALLOC_MODE_INTERNAL
return heap_caps_realloc(ptr, size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#elif CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL
return heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
#elif CONFIG_ESP_MATTER_MEM_ALLOC_MODE_IRAM_8BIT
return heap_caps_realloc_prefer(ptr, size, 2, MALLOC_CAP_INTERNAL | MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
#else
return realloc(ptr, size);
#endif
}
IRAM_ATTR void esp_matter_mem_free(void *ptr)
{
#if CONFIG_ESP_MATTER_MEM_ALLOC_MODE_DEFAULT
+7 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
// Copyright 2023 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -24,3 +24,9 @@ void *esp_matter_mem_calloc(size_t n, size_t size);
* @param[in] ptr pointer to the memory to be freed.
*/
void esp_matter_mem_free(void *ptr);
/** ESP Matter realloc
* @param[in] ptr Pointer to reallocate
* @param[in] size size to reallocate
*/
void *esp_matter_mem_realloc(void *ptr, size_t size);