/**1* @file lv_ll.c2* Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module.3*/45#ifndef LV_LL_H6#define LV_LL_H78#ifdef __cplusplus9extern "C" {10#endif111213/*********************14* INCLUDES15*********************/16#include "lv_mem.h"17#include <stdint.h>18#include <stddef.h>1920/*********************21* DEFINES22*********************/2324/**********************25* TYPEDEFS26**********************/2728/*Dummy type to make handling easier*/29typedef uint8_t lv_ll_node_t;3031/*Description of a linked list*/32typedef struct33{34uint32_t n_size;35lv_ll_node_t* head;36lv_ll_node_t* tail;37} lv_ll_t;3839/**********************40* GLOBAL PROTOTYPES41**********************/4243/**44* Initialize linked list45* @param ll_dsc pointer to ll_dsc variable46* @param node_size the size of 1 node in bytes47*/48void lv_ll_init(lv_ll_t * ll_p, uint32_t node_size);4950/**51* Add a new head to a linked list52* @param ll_p pointer to linked list53* @return pointer to the new head54*/55void * lv_ll_ins_head(lv_ll_t * ll_p);5657/**58* Insert a new node in front of the n_act node59* @param ll_p pointer to linked list60* @param n_act pointer a node61* @return pointer to the new head62*/63void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act);6465/**66* Add a new tail to a linked list67* @param ll_p pointer to linked list68* @return pointer to the new tail69*/70void * lv_ll_ins_tail(lv_ll_t * ll_p);7172/**73* Remove the node 'node_p' from 'll_p' linked list.74* It does not free the the memory of node.75* @param ll_p pointer to the linked list of 'node_p'76* @param node_p pointer to node in 'll_p' linked list77*/78void lv_ll_rem(lv_ll_t * ll_p, void * node_p);7980/**81* Remove and free all elements from a linked list. The list remain valid but become empty.82* @param ll_p pointer to linked list83*/84void lv_ll_clear(lv_ll_t * ll_p);8586/**87* Move a node to a new linked list88* @param ll_ori_p pointer to the original (old) linked list89* @param ll_new_p pointer to the new linked list90* @param node pointer to a node91* @return head changed92*/93bool lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node);9495/**96* Return with head node of the linked list97* @param ll_p pointer to linked list98* @return pointer to the head of 'll_p'99*/100void * lv_ll_get_head(const lv_ll_t * ll_p);101102/**103* Return with tail node of the linked list104* @param ll_p pointer to linked list105* @return pointer to the head of 'll_p'106*/107void * lv_ll_get_tail(const lv_ll_t * ll_p);108109/**110* Return with the pointer of the next node after 'n_act'111* @param ll_p pointer to linked list112* @param n_act pointer a node113* @return pointer to the next node114*/115void * lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act);116117/**118* Return with the pointer of the previous node after 'n_act'119* @param ll_p pointer to linked list120* @param n_act pointer a node121* @return pointer to the previous node122*/123void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act);124125/**126* Move a nodw before an other node in the same linked list127* @param ll_p pointer to a linked list128* @param n_act pointer to node to move129* @param n_after pointer to a node which should be after `n_act`130*/131void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after);132133/**********************134* MACROS135**********************/136137#define LL_READ(list, i) for(i = lv_ll_get_head(&list); i != NULL; i = lv_ll_get_next(&list, i))138139#define LL_READ_BACK(list, i) for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i))140141#ifdef __cplusplus142} /* extern "C" */143#endif144145#endif146147148