lv_mem.h

Functions

void *lv_malloc(size_t size)

Allocate a memory dynamically

Parameters:

size -- size of the memory to allocate in bytes

Returns:

pointer to the allocated memory

void lv_free(void *data)

Free an allocated data

Parameters:

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.

Parameters:
  • 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

Returns:

pointer to the new memory, NULL on failure

void *lv_memcpy(void *dst, const void *src, size_t len)

Copies a block of memory from a source address to a destination address.

Note

The function does not check for any overlapping of the source and destination memory blocks.

Parameters:
  • dst -- Pointer to the destination array where the content is to be copied.

  • src -- Pointer to the source of data to be copied.

  • len -- Number of bytes to copy.

Returns:

Pointer to the destination array.

void lv_memset(void *dst, uint8_t v, size_t len)

Fills a block of memory with a specified value.

Parameters:
  • dst -- Pointer to the destination array to fill with the specified value.

  • v -- Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value.

  • len -- Number of bytes to be set to the value.

static inline void lv_memzero(void *dst, size_t len)

Same as memset(dst, 0x00, len).

Parameters:
  • dst -- pointer to the destination buffer

  • len -- number of byte to set

size_t lv_strlen(const char *str)

Computes the length of the string str up to, but not including the terminating null character.

Parameters:

str -- Pointer to the null-terminated byte string to be examined.

Returns:

The length of the string in bytes.

char *lv_strncpy(char *dst, const char *src, size_t dest_size)

Copies up to dest_size characters from the string pointed to by src to the character array pointed to by dst.

Parameters:
  • dst -- Pointer to the destination array where the content is to be copied.

  • src -- Pointer to the source of data to be copied.

  • dest_size -- Maximum number of characters to be copied to dst, including the null character.

Returns:

A pointer to the destination array, which is dst.

char *lv_strcpy(char *dst, const char *src)

Copies the string pointed to by src, including the terminating null character, to the character array pointed to by dst.

Parameters:
  • dst -- Pointer to the destination array where the content is to be copied.

  • src -- Pointer to the source of data to be copied.

Returns:

A pointer to the destination array, which is dst.

lv_res_t lv_mem_test(void)

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

Returns:

LV_RES_OK if the memory allocation system is working properly, or LV_RES_INV if there is an error.

void lv_mem_monitor(lv_mem_monitor_t *mon_p)

Give information about the work memory of dynamic allocation

Parameters:

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

uint32_t total_size

Total heap size

uint32_t free_cnt
uint32_t free_size

Size of available memory

uint32_t free_biggest_size
uint32_t used_cnt
uint32_t max_used

Max size of Heap memory used

uint8_t used_pct

Percentage used

uint8_t frag_pct

Amount of fragmentation