Skip to content

Commit

Permalink
feat(micropython): improve mem core micropython
Browse files Browse the repository at this point in the history
Allow using `MICROPY_MALLOC_USES_ALLOCATED_SIZE` option
required to build `lv_bindings_micropython` with upstream
MicroPython.

Required for lvgl/lv_binding_micropython#242
  • Loading branch information
Carglglz committed May 12, 2024
1 parent b16aa3c commit c57190d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/stdlib/micropython/lv_mem_core_micropython.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c57190d

Please sign in to comment.