lv_string.h

Functions

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.

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

Move a block of memory from source to destination.

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.

int lv_memcmp(const void *p1, const void *p2, size_t len)

This function will compare two memory blocks.

Parameters:
  • p1 – Pointer to the first memory block

  • p2 – Pointer to the second memory block

  • len – Number of bytes to compare

Returns:

The difference between the value of the first unmatching byte.

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.

size_t lv_strlcpy(char *dst, const char *src, size_t dst_size)

Copies up to dst_size-1 (non-null) characters from src to dst. A null terminator is always added.

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

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

  • dst_size – Maximum number of characters to be copied to dst, including the null character.

Returns:

The length of src. The return value is equivalent to the value returned by lv_strlen(src)

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 and fills the remaining length with null bytes.

Note

dst will not be null terminated if dest_size bytes were copied from src before the end of src was reached.

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.

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.

int lv_strcmp(const char *s1, const char *s2)

This function will compare two strings without specified length.

Parameters:
  • s1 – pointer to the first string

  • s2 – pointer to the second string

Returns:

the difference between the value of the first unmatching character.

int lv_strncmp(const char *s1, const char *s2, size_t len)

This function will compare two strings up to the given length.

Parameters:
  • s1 – pointer to the first string

  • s2 – pointer to the second string

  • len – the maximum amount of characters to compare

Returns:

the difference between the value of the first unmatching character.

static inline bool lv_streq(const char *s1, const char *s2)

Returns true if the two strings are equal. Just a wrapper around strcmp for convenience.

Parameters:
  • s1 – pointer to the first string

  • s2 – pointer to the second string

Returns:

true: the strings are equal; false: otherwise

char *lv_strdup(const char *src)

Duplicate a string by allocating a new one and copying the content.

Parameters:

src – Pointer to the source of data to be copied.

Returns:

A pointer to the new allocated string. NULL if failed.

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

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

Parameters:
  • dst – Pointer to the destination string where the content is to be appended.

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

Returns:

A pointer to the destination string, which is dst.

char *lv_strncat(char *dst, const char *src, size_t src_len)

Copies up to src_len characters from the string pointed to by src to the end of the string pointed to by dst. A terminating null character is appended to dst even if no null character was encountered in src after src_len characters were copied.

Parameters:
  • dst – Pointer to the destination string where the content is to be appended.

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

  • src_len – Maximum number of characters from src to be copied to the end of dst.

Returns:

A pointer to the destination string, which is dst.

char *lv_strchr(const char *str, int c)

Searches for the first occurrence of character c in the string str.

Parameters:
  • str – Pointer to the null-terminated byte string to be searched.

  • c – The character to be searched for.

Returns:

A pointer to the first occurrence of character c in the string str, or a null pointer if c is not found.