lv_ll.h

Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module.

Defines

LV_LL_READ(list, i)
LV_LL_READ_BACK(list, i)

Typedefs

typedef uint8_t lv_ll_node_t

Dummy type to make handling easier

Functions

void lv_ll_init(lv_ll_t *ll_p, uint32_t node_size)

Initialize linked list

Parameters:
  • ll_p – pointer to lv_ll_t variable

  • node_size – the size of 1 node in bytes

void *lv_ll_ins_head(lv_ll_t *ll_p)

Add a new head to a linked list

Parameters:

ll_p – pointer to linked list

Returns:

pointer to the new head

void *lv_ll_ins_prev(lv_ll_t *ll_p, void *n_act)

Insert a new node in front of the n_act node

Parameters:
  • ll_p – pointer to linked list

  • n_act – pointer a node

Returns:

pointer to the new node

void *lv_ll_ins_tail(lv_ll_t *ll_p)

Add a new tail to a linked list

Parameters:

ll_p – pointer to linked list

Returns:

pointer to the new tail

void lv_ll_remove(lv_ll_t *ll_p, void *node_p)

Remove the node 'node_p' from 'll_p' linked list. It does not free the memory of node.

Parameters:
  • ll_p – pointer to the linked list of 'node_p'

  • node_p – pointer to node in 'll_p' linked list

void lv_ll_clear_custom(lv_ll_t *ll_p, void (*cleanup)(void*))
void lv_ll_clear(lv_ll_t *ll_p)

Remove and free all elements from a linked list. The list remain valid but become empty.

Parameters:

ll_p – pointer to linked list

void lv_ll_chg_list(lv_ll_t *ll_ori_p, lv_ll_t *ll_new_p, void *node, bool head)

Move a node to a new linked list

Parameters:
  • ll_ori_p – pointer to the original (old) linked list

  • ll_new_p – pointer to the new linked list

  • node – pointer to a node

  • head – true: be the head in the new list false be the tail in the new list

void *lv_ll_get_head(const lv_ll_t *ll_p)

Return with head node of the linked list

Parameters:

ll_p – pointer to linked list

Returns:

pointer to the head of 'll_p'

void *lv_ll_get_tail(const lv_ll_t *ll_p)

Return with tail node of the linked list

Parameters:

ll_p – pointer to linked list

Returns:

pointer to the tail of 'll_p'

void *lv_ll_get_next(const lv_ll_t *ll_p, const void *n_act)

Return with the pointer of the next node after 'n_act'

Parameters:
  • ll_p – pointer to linked list

  • n_act – pointer a node

Returns:

pointer to the next node

void *lv_ll_get_prev(const lv_ll_t *ll_p, const void *n_act)

Return with the pointer of the previous node after 'n_act'

Parameters:
  • ll_p – pointer to linked list

  • n_act – pointer a node

Returns:

pointer to the previous node

uint32_t lv_ll_get_len(const lv_ll_t *ll_p)

Return the length of the linked list.

Parameters:

ll_p – pointer to linked list

Returns:

length of the linked list

void lv_ll_move_before(lv_ll_t *ll_p, void *n_act, void *n_after)

Move a node before another node in the same linked list

Parameters:
  • ll_p – pointer to a linked list

  • n_act – pointer to node to move

  • n_after – pointer to a node which should be after n_act

bool lv_ll_is_empty(lv_ll_t *ll_p)

Check if a linked list is empty

Parameters:

ll_p – pointer to a linked list

Returns:

true: the linked list is empty; false: not empty

struct lv_ll_t
#include <lv_ll.h>

Description of a linked list

Public Members

uint32_t n_size
lv_ll_node_t *head
lv_ll_node_t *tail