Lines Matching refs:ll_p
17 #define LL_PREV_P_OFFSET(ll_p) (ll_p->n_size) argument
18 #define LL_NEXT_P_OFFSET(ll_p) (ll_p->n_size + sizeof(lv_ll_node_t *)) argument
27 static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * prev);
28 static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * next);
47 void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size) in _lv_ll_init() argument
49 ll_p->head = NULL; in _lv_ll_init()
50 ll_p->tail = NULL; in _lv_ll_init()
59 ll_p->n_size = node_size; in _lv_ll_init()
67 void * _lv_ll_ins_head(lv_ll_t * ll_p) in _lv_ll_ins_head() argument
71 n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); in _lv_ll_ins_head()
74 node_set_prev(ll_p, n_new, NULL); /*No prev. before the new head*/ in _lv_ll_ins_head()
75 node_set_next(ll_p, n_new, ll_p->head); /*After new comes the old head*/ in _lv_ll_ins_head()
77 if(ll_p->head != NULL) { /*If there is old head then before it goes the new*/ in _lv_ll_ins_head()
78 node_set_prev(ll_p, ll_p->head, n_new); in _lv_ll_ins_head()
81 ll_p->head = n_new; /*Set the new head in the dsc.*/ in _lv_ll_ins_head()
82 if(ll_p->tail == NULL) { /*If there is no tail (1. node) set the tail too*/ in _lv_ll_ins_head()
83 ll_p->tail = n_new; in _lv_ll_ins_head()
96 void * _lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act) in _lv_ll_ins_prev() argument
100 if(NULL == ll_p || NULL == n_act) return NULL; in _lv_ll_ins_prev()
102 if(_lv_ll_get_head(ll_p) == n_act) { in _lv_ll_ins_prev()
103 n_new = _lv_ll_ins_head(ll_p); in _lv_ll_ins_prev()
107 n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); in _lv_ll_ins_prev()
111 n_prev = _lv_ll_get_prev(ll_p, n_act); in _lv_ll_ins_prev()
112 node_set_next(ll_p, n_prev, n_new); in _lv_ll_ins_prev()
113 node_set_prev(ll_p, n_new, n_prev); in _lv_ll_ins_prev()
114 node_set_prev(ll_p, n_act, n_new); in _lv_ll_ins_prev()
115 node_set_next(ll_p, n_new, n_act); in _lv_ll_ins_prev()
126 void * _lv_ll_ins_tail(lv_ll_t * ll_p) in _lv_ll_ins_tail() argument
130 n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); in _lv_ll_ins_tail()
133 node_set_next(ll_p, n_new, NULL); /*No next after the new tail*/ in _lv_ll_ins_tail()
134 node_set_prev(ll_p, n_new, ll_p->tail); /*The prev. before new is the old tail*/ in _lv_ll_ins_tail()
135 if(ll_p->tail != NULL) { /*If there is old tail then the new comes after it*/ in _lv_ll_ins_tail()
136 node_set_next(ll_p, ll_p->tail, n_new); in _lv_ll_ins_tail()
139 ll_p->tail = n_new; /*Set the new tail in the dsc.*/ in _lv_ll_ins_tail()
140 if(ll_p->head == NULL) { /*If there is no head (1. node) set the head too*/ in _lv_ll_ins_tail()
141 ll_p->head = n_new; in _lv_ll_ins_tail()
154 void _lv_ll_remove(lv_ll_t * ll_p, void * node_p) in _lv_ll_remove() argument
156 if(ll_p == NULL) return; in _lv_ll_remove()
158 if(_lv_ll_get_head(ll_p) == node_p) { in _lv_ll_remove()
160 ll_p->head = _lv_ll_get_next(ll_p, node_p); in _lv_ll_remove()
161 if(ll_p->head == NULL) { in _lv_ll_remove()
162 ll_p->tail = NULL; in _lv_ll_remove()
165 node_set_prev(ll_p, ll_p->head, NULL); in _lv_ll_remove()
168 else if(_lv_ll_get_tail(ll_p) == node_p) { in _lv_ll_remove()
170 ll_p->tail = _lv_ll_get_prev(ll_p, node_p); in _lv_ll_remove()
171 if(ll_p->tail == NULL) { in _lv_ll_remove()
172 ll_p->head = NULL; in _lv_ll_remove()
175 node_set_next(ll_p, ll_p->tail, NULL); in _lv_ll_remove()
179 lv_ll_node_t * n_prev = _lv_ll_get_prev(ll_p, node_p); in _lv_ll_remove()
180 lv_ll_node_t * n_next = _lv_ll_get_next(ll_p, node_p); in _lv_ll_remove()
182 node_set_next(ll_p, n_prev, n_next); in _lv_ll_remove()
183 node_set_prev(ll_p, n_next, n_prev); in _lv_ll_remove()
191 void _lv_ll_clear(lv_ll_t * ll_p) in _lv_ll_clear() argument
196 i = _lv_ll_get_head(ll_p); in _lv_ll_clear()
200 i_next = _lv_ll_get_next(ll_p, i); in _lv_ll_clear()
202 _lv_ll_remove(ll_p, i); in _lv_ll_clear()
256 void * _lv_ll_get_head(const lv_ll_t * ll_p) in _lv_ll_get_head() argument
258 if(ll_p == NULL) return NULL; in _lv_ll_get_head()
259 return ll_p->head; in _lv_ll_get_head()
267 void * _lv_ll_get_tail(const lv_ll_t * ll_p) in _lv_ll_get_tail() argument
269 if(ll_p == NULL) return NULL; in _lv_ll_get_tail()
270 return ll_p->tail; in _lv_ll_get_tail()
279 void * _lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act) in _lv_ll_get_next() argument
284 n_act_d += LL_NEXT_P_OFFSET(ll_p); in _lv_ll_get_next()
294 void * _lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act) in _lv_ll_get_prev() argument
299 n_act_d += LL_PREV_P_OFFSET(ll_p); in _lv_ll_get_prev()
308 uint32_t _lv_ll_get_len(const lv_ll_t * ll_p) in _lv_ll_get_len() argument
313 for(node = _lv_ll_get_head(ll_p); node != NULL; node = _lv_ll_get_next(ll_p, node)) { in _lv_ll_get_len()
326 void _lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after) in _lv_ll_move_before() argument
332 n_before = _lv_ll_get_prev(ll_p, n_after); in _lv_ll_move_before()
334 n_before = _lv_ll_get_tail(ll_p); /*if `n_after` is NULL `n_act` should be the new tail*/ in _lv_ll_move_before()
339 _lv_ll_remove(ll_p, n_act); in _lv_ll_move_before()
342 node_set_next(ll_p, n_before, n_act); in _lv_ll_move_before()
343 node_set_prev(ll_p, n_act, n_before); in _lv_ll_move_before()
344 node_set_prev(ll_p, n_after, n_act); in _lv_ll_move_before()
345 node_set_next(ll_p, n_act, n_after); in _lv_ll_move_before()
348 if(n_after == NULL) ll_p->tail = n_act; in _lv_ll_move_before()
351 if(n_before == NULL) ll_p->head = n_act; in _lv_ll_move_before()
359 bool _lv_ll_is_empty(lv_ll_t * ll_p) in _lv_ll_is_empty() argument
361 if(ll_p == NULL) return true; in _lv_ll_is_empty()
363 if(ll_p->head == NULL && ll_p->tail == NULL) return true; in _lv_ll_is_empty()
378 static void node_set_prev(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * prev) in node_set_prev() argument
384 act8 += LL_PREV_P_OFFSET(ll_p); in node_set_prev()
398 static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * next) in node_set_next() argument
403 act8 += LL_NEXT_P_OFFSET(ll_p); in node_set_next()