Skip to content

Commit c57190d

Browse files
committed
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 lvgl/lv_binding_micropython#242
1 parent b16aa3c commit c57190d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/stdlib/micropython/lv_mem_core_micropython.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,32 @@ void lv_mem_remove_pool(lv_mem_pool_t pool)
6262

6363
void * lv_malloc_core(size_t size)
6464
{
65+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
66+
return gc_alloc(size, true);
67+
#else
6568
return m_malloc(size);
69+
#endif
6670
}
6771

6872
void * lv_realloc_core(void * p, size_t new_size)
6973
{
74+
75+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
76+
return gc_realloc(p, new_size, true);
77+
#else
7078
return m_realloc(p, new_size);
79+
#endif
7180
}
7281

7382
void lv_free_core(void * p)
7483
{
84+
85+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
86+
gc_free(p);
87+
88+
#else
7589
m_free(p);
90+
#endif
7691
}
7792

7893
void lv_mem_monitor_core(lv_mem_monitor_t * mon_p)

0 commit comments

Comments
 (0)