Lines Matching refs:l

26 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
28 l->head = NULL; in zend_llist_init()
29 l->tail = NULL; in zend_llist_init()
30 l->count = 0; in zend_llist_init()
31 l->size = size; in zend_llist_init()
32 l->dtor = dtor; in zend_llist_init()
33 l->persistent = persistent; in zend_llist_init()
37 ZEND_API void zend_llist_add_element(zend_llist *l, void *element) in zend_llist_add_element() argument
39 zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent); in zend_llist_add_element()
41 tmp->prev = l->tail; in zend_llist_add_element()
43 if (l->tail) { in zend_llist_add_element()
44 l->tail->next = tmp; in zend_llist_add_element()
46 l->head = tmp; in zend_llist_add_element()
48 l->tail = tmp; in zend_llist_add_element()
49 memcpy(tmp->data, element, l->size); in zend_llist_add_element()
51 ++l->count; in zend_llist_add_element()
55 ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element) in zend_llist_prepend_element() argument
57 zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent); in zend_llist_prepend_element()
59 tmp->next = l->head; in zend_llist_prepend_element()
61 if (l->head) { in zend_llist_prepend_element()
62 l->head->prev = tmp; in zend_llist_prepend_element()
64 l->tail = tmp; in zend_llist_prepend_element()
66 l->head = tmp; in zend_llist_prepend_element()
67 memcpy(tmp->data, element, l->size); in zend_llist_prepend_element()
69 ++l->count; in zend_llist_prepend_element()
73 #define DEL_LLIST_ELEMENT(current, l) \ argument
77 (l)->head = (current)->next;\
82 (l)->tail = (current)->prev;\
84 if ((l)->dtor) {\
85 (l)->dtor((current)->data);\
87 pefree((current), (l)->persistent);\
88 --l->count;
91 ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, v… in zend_llist_del_element() argument
93 zend_llist_element *current=l->head; in zend_llist_del_element()
97 DEL_LLIST_ELEMENT(current, l); in zend_llist_del_element()
105 ZEND_API void zend_llist_destroy(zend_llist *l) in zend_llist_destroy() argument
107 zend_llist_element *current=l->head, *next; in zend_llist_destroy()
111 if (l->dtor) { in zend_llist_destroy()
112 l->dtor(current->data); in zend_llist_destroy()
114 pefree(current, l->persistent); in zend_llist_destroy()
118 l->count = 0; in zend_llist_destroy()
122 ZEND_API void zend_llist_clean(zend_llist *l) in zend_llist_clean() argument
124 zend_llist_destroy(l); in zend_llist_clean()
125 l->head = l->tail = NULL; in zend_llist_clean()
129 ZEND_API void *zend_llist_remove_tail(zend_llist *l) in zend_llist_remove_tail() argument
134 if ((old_tail = l->tail)) { in zend_llist_remove_tail()
138 l->head = NULL; in zend_llist_remove_tail()
143 l->tail = old_tail->prev; in zend_llist_remove_tail()
144 if (l->dtor) { in zend_llist_remove_tail()
145 l->dtor(data); in zend_llist_remove_tail()
147 pefree(old_tail, l->persistent); in zend_llist_remove_tail()
149 --l->count; in zend_llist_remove_tail()
171 ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)) in zend_llist_apply_with_del() argument
175 element=l->head; in zend_llist_apply_with_del()
179 DEL_LLIST_ELEMENT(element, l); in zend_llist_apply_with_del()
186 ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC) in zend_llist_apply() argument
190 for (element=l->head; element; element=element->next) { in zend_llist_apply()
195 ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRMLS_DC) in zend_llist_sort() argument
202 if (l->count <= 0) { in zend_llist_sort()
206 elements = (zend_llist_element **) emalloc(l->count * sizeof(zend_llist_element *)); in zend_llist_sort()
210 for (element=l->head; element; element=element->next) { in zend_llist_sort()
214 zend_qsort(elements, l->count, sizeof(zend_llist_element *), (compare_func_t) comp_func TSRMLS_CC); 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 TSRM… 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 int 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()