lvgl: provide lvgl_realloc()

In order to support lvgl v8, we need to provide a realloc() implementation
in our custom sys_heap allocator. This uses sys_heap_realloc() internally
and exposes traditional realloc() semantics.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@huawei.com>
This commit is contained in:
Bartosz Golaszewski 2021-12-17 18:42:24 +01:00 committed by Carles Cufí
parent b7dbe1a51e
commit 1e80d5a954
2 changed files with 14 additions and 0 deletions

View file

@ -30,6 +30,18 @@ void *lvgl_malloc(size_t size)
return ret;
}
void *lvgl_realloc(void *ptr, size_t size)
{
k_spinlock_key_t key;
void *ret;
key = k_spin_lock(&lvgl_heap_lock);
ret = sys_heap_realloc(&lvgl_heap, ptr, size);
k_spin_unlock(&lvgl_heap_lock, key);
return ret;
}
void lvgl_free(void *ptr)
{
k_spinlock_key_t key;

View file

@ -15,6 +15,8 @@ extern "C" {
void *lvgl_malloc(size_t size);
void *lvgl_realloc(void *ptr, size_t size);
void lvgl_free(void *ptr);
#ifdef __cplusplus