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()
99 DEL_LLIST_ELEMENT(current, l); in zend_llist_del_element()
107 ZEND_API void zend_llist_destroy(zend_llist *l) in zend_llist_destroy() argument
109 zend_llist_element *current=l->head, *next; in zend_llist_destroy()
113 if (l->dtor) { in zend_llist_destroy()
114 l->dtor(current->data); in zend_llist_destroy()
116 pefree(current, l->persistent); in zend_llist_destroy()
120 l->count = 0; in zend_llist_destroy()
124 ZEND_API void zend_llist_clean(zend_llist *l) in zend_llist_clean() argument
126 zend_llist_destroy(l); in zend_llist_clean()
127 l->head = l->tail = NULL; in zend_llist_clean()
131 ZEND_API void *zend_llist_remove_tail(zend_llist *l) in zend_llist_remove_tail() argument
136 if ((old_tail = l->tail)) { in zend_llist_remove_tail()
140 l->head = NULL; in zend_llist_remove_tail()
145 l->tail = old_tail->prev; in zend_llist_remove_tail()
146 if (l->dtor) { in zend_llist_remove_tail()
147 l->dtor(data); in zend_llist_remove_tail()
149 pefree(old_tail, l->persistent); in zend_llist_remove_tail()
151 --l->count; in zend_llist_remove_tail()
173 ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)) in zend_llist_apply_with_del() argument
177 element=l->head; in zend_llist_apply_with_del()
181 DEL_LLIST_ELEMENT(element, l); in zend_llist_apply_with_del()
188 ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func TSRMLS_DC) in zend_llist_apply() argument
192 for (element=l->head; element; element=element->next) { in zend_llist_apply()
197 ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func TSRMLS_DC) in zend_llist_sort() argument
204 if (l->count <= 0) { in zend_llist_sort()
208 elements = (zend_llist_element **) emalloc(l->count * sizeof(zend_llist_element *)); in zend_llist_sort()
212 for (element=l->head; element; element=element->next) { in zend_llist_sort()
216 zend_qsort(elements, l->count, sizeof(zend_llist_element *), (compare_func_t) comp_func TSRMLS_CC); in zend_llist_sort()
218 l->head = elements[0]; in zend_llist_sort()
221 for (i = 1; i < l->count; i++) { in zend_llist_sort()
226 l->tail = elements[i-1]; in zend_llist_sort()
231 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
235 for (element=l->head; element; element=element->next) { in zend_llist_apply_with_argument()
241 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
247 for (element=l->head; element; element=element->next) { in zend_llist_apply_with_arguments()
254 ZEND_API int zend_llist_count(zend_llist *l) in zend_llist_count() argument
256 return l->count; in zend_llist_count()
260 ZEND_API void *zend_llist_get_first_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_first_ex() argument
262 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_first_ex()
264 *current = l->head; in zend_llist_get_first_ex()
273 ZEND_API void *zend_llist_get_last_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_last_ex() argument
275 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_last_ex()
277 *current = l->tail; in zend_llist_get_last_ex()
286 ZEND_API void *zend_llist_get_next_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_next_ex() argument
288 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_next_ex()
300 ZEND_API void *zend_llist_get_prev_ex(zend_llist *l, zend_llist_position *pos) in zend_llist_get_prev_ex() argument
302 zend_llist_position *current = pos ? pos : &l->traverse_ptr; in zend_llist_get_prev_ex()