From c57190d5d2323d3e7911a5bdcef9a7d677b52e2a Mon Sep 17 00:00:00 2001 From: Carlosgg Date: Sat, 30 Mar 2024 17:08:07 +0000 Subject: [PATCH] feat(micropython): improve mem core micropython Allow using `MICROPY_MALLOC_USES_ALLOCATED_SIZE` option required to build `lv_bindings_micropython` with upstream MicroPython. Required for https://github.com/lvgl/lv_binding_micropython/pull/242 --- src/stdlib/micropython/lv_mem_core_micropython.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/stdlib/micropython/lv_mem_core_micropython.c b/src/stdlib/micropython/lv_mem_core_micropython.c index 69c8bd681509..a671b5e1cc73 100644 --- a/src/stdlib/micropython/lv_mem_core_micropython.c +++ b/src/stdlib/micropython/lv_mem_core_micropython.c @@ -62,17 +62,32 @@ void lv_mem_remove_pool(lv_mem_pool_t pool) void * lv_malloc_core(size_t size) { +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE + return gc_alloc(size, true); +#else return m_malloc(size); +#endif } void * lv_realloc_core(void * p, size_t new_size) { + +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE + return gc_realloc(p, new_size, true); +#else return m_realloc(p, new_size); +#endif } void lv_free_core(void * p) { + +#if MICROPY_MALLOC_USES_ALLOCATED_SIZE + gc_free(p); + +#else m_free(p); +#endif } void lv_mem_monitor_core(lv_mem_monitor_t * mon_p)