lv_mem.h

Typedefs

typedef void *lv_mem_pool_t

Functions

void lv_mem_init(void)

Initialize to use malloc/free/realloc etc

void lv_mem_deinit(void)

Drop all dynamically allocated memory and reset the memory pools' state

lv_mem_pool_t lv_mem_add_pool(void *mem, size_t bytes)
void lv_mem_remove_pool(lv_mem_pool_t pool)
void *lv_malloc(size_t size)

Allocate memory dynamically

参数:

size -- requested size in bytes

返回:

pointer to allocated uninitialized memory, or NULL on failure

void *lv_malloc_zeroed(size_t size)

Allocate zeroed memory dynamically

参数:

size -- requested size in bytes

返回:

pointer to allocated zeroed memory, or NULL on failure

void lv_free(void *data)

Free an allocated data

参数:

data -- pointer to an allocated memory

void *lv_realloc(void *data_p, size_t new_size)

Reallocate a memory with a new size. The old content will be kept.

参数:
  • data_p -- pointer to an allocated memory. Its content will be copied to the new memory block and freed

  • new_size -- the desired new size in byte

返回:

pointer to the new memory, NULL on failure

void *lv_malloc_core(size_t size)

Used internally to execute a plain malloc operation

参数:

size -- size in bytes to malloc

void lv_free_core(void *p)

Used internally to execute a plain free operation

参数:

p -- memory address to free

void *lv_realloc_core(void *p, size_t new_size)

Used internally to execute a plain realloc operation

参数:
  • p -- memory address to realloc

  • new_size -- size in bytes to realloc

void lv_mem_monitor_core(lv_mem_monitor_t *mon_p)

Used internally to execute a plain malloc operation

参数:

size -- size in bytes to malloc

lv_result_t lv_mem_test_core(void)
lv_result_t lv_mem_test(void)

Tests the memory allocation system by allocating and freeing a block of memory.

返回:

LV_RESULT_OK if the memory allocation system is working properly, or LV_RESULT_INVALID if there is an error.

void lv_mem_monitor(lv_mem_monitor_t *mon_p)

Give information about the work memory of dynamic allocation

参数:

mon_p -- pointer to a lv_mem_monitor_t variable, the result of the analysis will be stored here

struct lv_mem_monitor_t
#include <lv_mem.h>

Heap information structure.

Public Members

size_t total_size

Total heap size

size_t free_cnt
size_t free_size

Size of available memory

size_t free_biggest_size
size_t used_cnt
size_t max_used

Max size of Heap memory used

uint8_t used_pct

Percentage used

uint8_t frag_pct

Amount of fragmentation