Lines Matching refs:l

24 ZEND_API void zend_llist_init(zend_llist *l, size_t size, llist_dtor_func_t dtor, unsigned char per…  in zend_llist_init()  argument
26 l->head = NULL; in zend_llist_init()
27 l->tail = NULL; in zend_llist_init()
28 l->count = 0; in zend_llist_init()
29 l->size = size; in zend_llist_init()
30 l->dtor = dtor; in zend_llist_init()
31 l->persistent = persistent; in zend_llist_init()
34 ZEND_API void zend_llist_add_element(zend_llist *l, const void *element) in zend_llist_add_element() argument
36 zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent); in zend_llist_add_element()
38 tmp->prev = l->tail; in zend_llist_add_element()
40 if (l->tail) { in zend_llist_add_element()
41 l->tail->next = tmp; in zend_llist_add_element()
43 l->head = tmp; in zend_llist_add_element()
45 l->tail = tmp; in zend_llist_add_element()
46 memcpy(tmp->data, element, l->size); in zend_llist_add_element()
48 ++l->count; in zend_llist_add_element()
52 ZEND_API void zend_llist_prepend_element(zend_llist *l, const void *element) in zend_llist_prepend_element() argument
54 zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent); in zend_llist_prepend_element()
56 tmp->next = l->head; in zend_llist_prepend_element()
58 if (l->head) { in zend_llist_prepend_element()
59 l->head->prev = tmp; in zend_llist_prepend_element()
61 l->tail = tmp; in zend_llist_prepend_element()
63 l->head = tmp; in zend_llist_prepend_element()
64 memcpy(tmp->data, element, l->size); in zend_llist_prepend_element()
66 ++l->count; in zend_llist_prepend_element()
70 #define DEL_LLIST_ELEMENT(current, l) \ argument
74 (l)->head = (current)->next;\
79 (l)->tail = (current)->prev;\
81 if ((l)->dtor) {\
82 (l)->dtor((current)->data);\
84 pefree((current), (l)->persistent);\
85 --l->count;
88 ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, v… in zend_llist_del_element() argument
90 zend_llist_element *current=l->head; in zend_llist_del_element()
94 DEL_LLIST_ELEMENT(current, l); in zend_llist_del_element()
102 ZEND_API void zend_llist_destroy(zend_llist *l) in zend_llist_destroy() argument
104 zend_llist_element *current=l->head, *next; in zend_llist_destroy()
108 if (l->dtor) { in zend_llist_destroy()
109 l->dtor(current->data); in zend_llist_destroy()
111 pefree(current, l->persistent); in zend_llist_destroy()
115 l->count = 0; in zend_llist_destroy()
119 ZEND_API void zend_llist_clean(zend_llist *l) in zend_llist_clean() argument
121 zend_llist_destroy(l); in zend_llist_clean()
122 l->head = l->tail = NULL; in zend_llist_clean()
126 ZEND_API void zend_llist_remove_tail(zend_llist *l) in zend_llist_remove_tail() argument
128 zend_llist_element *old_tail = l->tail; in zend_llist_remove_tail()
136 l->head = NULL; in zend_llist_remove_tail()
139 l->tail = old_tail->prev; in zend_llist_remove_tail()
140 --l->count; in zend_llist_remove_tail()
142 if (l->dtor) { in zend_llist_remove_tail()
143 l->dtor(old_tail->data); in zend_llist_remove_tail()
145 pefree(old_tail, l->persistent); in zend_llist_remove_tail()
162 ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)) in zend_llist_apply_with_del() argument
166 element=l->head; in zend_llist_apply_with_del()
170 DEL_LLIST_ELEMENT(element, l); in zend_llist_apply_with_del()
177 ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func) in zend_llist_apply() argument
181 for (element=l->head; element; element=element->next) { in zend_llist_apply()
194 ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func) in zend_llist_sort() argument
201 if (l->count == 0) { in zend_llist_sort()
205 elements = (zend_llist_element **) emalloc(l->count * sizeof(zend_llist_element *)); in zend_llist_sort()
209 for (element=l->head; element; element=element->next) { in zend_llist_sort()
213 zend_sort(elements, l->count, sizeof(zend_llist_element *), in zend_llist_sort()
216 l->head = elements[0]; in zend_llist_sort()
219 for (i = 1; i < l->count; i++) { in zend_llist_sort()
224 l->tail = elements[i-1]; in zend_llist_sort()
229 ZEND_API void zend_llist_apply_with_argument(zend_llist *l, llist_apply_with_arg_func_t func, void … in zend_llist_apply_with_argument() argument
233 for (element=l->head; element; element=element->next) { in zend_llist_apply_with_argument()
239 ZEND_API void zend_llist_apply_with_arguments(zend_llist *l, llist_apply_with_args_func_t func, int… in zend_llist_apply_with_arguments() argument
245 for (element=l->head; element; element=element->next) { in zend_llist_apply_with_arguments()
252 ZEND_API size_t zend_llist_count(zend_llist *l) in zend_llist_count() argument
254 return l->count; in zend_llist_count()
258 ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_first_ex() argument
260 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_first_ex()
262 *current = l->head; in zend_llist_get_first_ex()
271 ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_last_ex() argument
273 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_last_ex()
275 *current = l->tail; in zend_llist_get_last_ex()
284 ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_next_ex() argument
286 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_next_ex()
298 ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_prev_ex() argument
300 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_prev_ex()