lib/gui/lvgl: Use a sys_heap and not a sys_mem_pool

The sys_mem_pool allocator is a legacy thing.  Use the standard heap
to reduce code size.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2020-09-22 14:50:18 -07:00 committed by Anas Nashif
commit 6bc6a67b0e
2 changed files with 13 additions and 11 deletions

View file

@ -7,7 +7,6 @@
#include "lvgl_mem.h"
#include <zephyr.h>
#include <init.h>
#include <sys/mempool.h>
Z_MEM_POOL_DEFINE(lvgl_mem_pool,
CONFIG_LVGL_MEM_POOL_MIN_SIZE,

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 Jan Van Winkel <jan.van_winkel@dxplore.eu>
* Copyright (c) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -7,27 +8,29 @@
#include "lvgl_mem.h"
#include <zephyr.h>
#include <init.h>
#include <sys/mempool.h>
#include <sys/sys_heap.h>
SYS_MEM_POOL_DEFINE(lvgl_mem_pool, NULL,
CONFIG_LVGL_MEM_POOL_MIN_SIZE,
CONFIG_LVGL_MEM_POOL_MAX_SIZE,
CONFIG_LVGL_MEM_POOL_NUMBER_BLOCKS, 4, .data);
#define HEAP_BYTES (CONFIG_LVGL_MEM_POOL_MAX_SIZE * \
CONFIG_LVGL_MEM_POOL_NUMBER_BLOCKS)
static char lvgl_heap_mem[HEAP_BYTES];
static struct sys_heap lvgl_heap;
void *lvgl_malloc(size_t size)
{
return sys_mem_pool_alloc(&lvgl_mem_pool, size);
return sys_heap_alloc(&lvgl_heap, size);
}
void lvgl_free(void *ptr)
{
sys_mem_pool_free(ptr);
sys_heap_free(&lvgl_heap, ptr);
}
static int lvgl_mem_pool_init(const struct device *unused)
static int lvgl_heap_init(const struct device *unused)
{
sys_mem_pool_init(&lvgl_mem_pool);
sys_heap_init(&lvgl_heap, &lvgl_heap_mem[0], HEAP_BYTES);
return 0;
}
SYS_INIT(lvgl_mem_pool_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
SYS_INIT(lvgl_heap_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);