mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user