From 928da7104699a28ad1a934306d9d6cb7e63ddb18 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Wed, 18 Oct 2000 20:15:53 +0000 Subject: - Try #2. Wasn't allowed to delete in the previous manner because we were in the middle of an llist_apply() --- Zend/zend_llist.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Zend/zend_llist.c') diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c index 5c10eee433..68d39282ff 100644 --- a/Zend/zend_llist.c +++ b/Zend/zend_llist.c @@ -139,6 +139,24 @@ ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src) } +ZEND_API void zend_llist_apply_with_del(zend_llist *l, int (*func)(void *data)) +{ + zend_llist_element *element, *next; + + element=l->head; + while (element) { + next = element->next; + if (func(element->data)) { + if (l->dtor) { + l->dtor(element->data); + pefree(element, l->persistent); + } + } + element = next; + } +} + + ZEND_API void zend_llist_apply(zend_llist *l, void (*func)(void *data)) { zend_llist_element *element; -- cgit v1.2.1