yamt commented on a change in pull request #2832: URL: https://github.com/apache/incubator-nuttx/pull/2832#discussion_r582625635
########## File path: arch/xtensa/src/esp32/esp32_wifi_adapter.c ########## @@ -3447,7 +3469,25 @@ static void *esp_malloc_internal(size_t size) static void *esp_realloc_internal(void *ptr, size_t size) { - return kmm_realloc(ptr, size); +#ifdef CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP + return xtensa_imm_realloc(ptr, size); +#else + void *p = NULL; + if (size == 0 || esp32_ptr_extram(ptr)) + { + kmm_free(ptr); + return NULL; + } + + p = kmm_realloc(ptr, size); + if (esp32_ptr_extram(ptr)) Review comment: do you mean `p`, not `ptr`? ########## File path: arch/xtensa/src/esp32/esp32_allocateheap.c ########## @@ -130,6 +143,10 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) { board_autoled_on(LED_HEAPALLOCATE); +#ifdef CONFIG_XTENSA_IMEM_MAXIMIZE_HEAP_REGION + *heap_size = HEAP_REGION_OFFSET; + *heap_start = (size_t)(HEAP_REGION1_END - *heap_size); Review comment: my question was "(size_t)". if it was "(FAR void *)", i can understand. does this even compile without warnings? ########## File path: arch/xtensa/src/esp32/esp32_wifi_adapter.c ########## @@ -3447,7 +3469,17 @@ static void *esp_malloc_internal(size_t size) static void *esp_realloc_internal(void *ptr, size_t size) { +#ifdef CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP + return xtensa_imm_realloc(ptr, size); +#else + if (size == 0 || esp32_ptr_extram(ptr)) + { + esp_free(ptr); + return NULL; Review comment: the esp-idf implementation does not seem to free the given `ptr` in case of error. eg. https://github.com/espressif/esp-idf/blob/master/components/heap/heap_caps.c#L323-L327 it matches my expectation for realloc(). i guess this implementation should do the same. unfortunately it seems ~impossible to implement it for !CONFIG_XTENSA_IMEM_USE_SEPARATE_HEAP case though. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org