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->head = NULL; in zend_llist_destroy()
116 l->tail = NULL; 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()