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()
36 ZEND_API void zend_llist_add_element(zend_llist *l, void *element) in zend_llist_add_element() argument
38 zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent); in zend_llist_add_element()
40 tmp->prev = l->tail; in zend_llist_add_element()
42 if (l->tail) { in zend_llist_add_element()
43 l->tail->next = tmp; in zend_llist_add_element()
45 l->head = tmp; in zend_llist_add_element()
47 l->tail = tmp; in zend_llist_add_element()
48 memcpy(tmp->data, element, l->size); in zend_llist_add_element()
50 ++l->count; in zend_llist_add_element()
54 ZEND_API void zend_llist_prepend_element(zend_llist *l, void *element) in zend_llist_prepend_element() argument
56 zend_llist_element *tmp = pemalloc(sizeof(zend_llist_element)+l->size-1, l->persistent); in zend_llist_prepend_element()
58 tmp->next = l->head; in zend_llist_prepend_element()
60 if (l->head) { in zend_llist_prepend_element()
61 l->head->prev = tmp; in zend_llist_prepend_element()
63 l->tail = tmp; in zend_llist_prepend_element()
65 l->head = tmp; in zend_llist_prepend_element()
66 memcpy(tmp->data, element, l->size); in zend_llist_prepend_element()
68 ++l->count; in zend_llist_prepend_element()
72 #define DEL_LLIST_ELEMENT(current, l) \ argument
76 (l)->head = (current)->next;\
81 (l)->tail = (current)->prev;\
83 if ((l)->dtor) {\
84 (l)->dtor((current)->data);\
86 pefree((current), (l)->persistent);\
87 --l->count;
90 ZEND_API void zend_llist_del_element(zend_llist *l, void *element, int (*compare)(void *element1, v… in zend_llist_del_element() argument
92 zend_llist_element *current=l->head; in zend_llist_del_element()
96 DEL_LLIST_ELEMENT(current, l); in zend_llist_del_element()
104 ZEND_API void zend_llist_destroy(zend_llist *l) in zend_llist_destroy() argument
106 zend_llist_element *current=l->head, *next; in zend_llist_destroy()
110 if (l->dtor) { in zend_llist_destroy()
111 l->dtor(current->data); in zend_llist_destroy()
113 pefree(current, l->persistent); in zend_llist_destroy()
117 l->count = 0; in zend_llist_destroy()
121 ZEND_API void zend_llist_clean(zend_llist *l) in zend_llist_clean() argument
123 zend_llist_destroy(l); in zend_llist_clean()
124 l->head = l->tail = NULL; in zend_llist_clean()
128 ZEND_API void zend_llist_remove_tail(zend_llist *l) in zend_llist_remove_tail() argument
130 zend_llist_element *old_tail = l->tail; in zend_llist_remove_tail()
138 l->head = NULL; in zend_llist_remove_tail()
141 l->tail = old_tail->prev; in zend_llist_remove_tail()
142 --l->count; in zend_llist_remove_tail()
144 if (l->dtor) { in zend_llist_remove_tail()
145 l->dtor(old_tail->data); in zend_llist_remove_tail()
147 pefree(old_tail, l->persistent); in zend_llist_remove_tail()
164 ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)) in zend_llist_apply_with_del() argument
168 element=l->head; in zend_llist_apply_with_del()
172 DEL_LLIST_ELEMENT(element, l); in zend_llist_apply_with_del()
179 ZEND_API void zend_llist_apply(zend_llist *l, llist_apply_func_t func) in zend_llist_apply() argument
183 for (element=l->head; element; element=element->next) { in zend_llist_apply()
196 ZEND_API void zend_llist_sort(zend_llist *l, llist_compare_func_t comp_func) in zend_llist_sort() argument
203 if (l->count <= 0) { in zend_llist_sort()
207 elements = (zend_llist_element **) emalloc(l->count * sizeof(zend_llist_element *)); in zend_llist_sort()
211 for (element=l->head; element; element=element->next) { in zend_llist_sort()
215 zend_sort(elements, l->count, sizeof(zend_llist_element *), 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, int… 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 size_t 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()