diff options
| -rw-r--r-- | Zend/zend_llist.c | 22 | ||||
| -rw-r--r-- | Zend/zend_llist.h | 1 |
2 files changed, 12 insertions, 11 deletions
diff --git a/Zend/zend_llist.c b/Zend/zend_llist.c index 2a659cef88..aabbe6ab21 100644 --- a/Zend/zend_llist.c +++ b/Zend/zend_llist.c @@ -72,26 +72,26 @@ ZEND_API void zend_llist_del_element(zend_llist *l, void *element) ZEND_API void zend_llist_destroy(zend_llist *l) { - zend_llist_element *current, *next; - - if (l->dtor) { - current = l->head; - - while (current) { - l->dtor(current->data); - current = current->next; - } - } + zend_llist_element *current=l->head, *next; - current = l->head; while (current) { next = current->next; + if (l->dtor) { + l->dtor(current->data); + } pefree(current, l->persistent); current = next; } } +ZEND_API void zend_llist_clean(zend_llist *l) +{ + zend_llist_destroy(l); + l->head = l->tail = NULL; +} + + ZEND_API void zend_llist_remove_tail(zend_llist *l) { zend_llist_element *old_tail; diff --git a/Zend/zend_llist.h b/Zend/zend_llist.h index 0c591f55d9..f268af9b97 100644 --- a/Zend/zend_llist.h +++ b/Zend/zend_llist.h @@ -38,6 +38,7 @@ ZEND_API void zend_llist_init(zend_llist *l, size_t size, void (*dtor)(void *dat ZEND_API void zend_llist_add_element(zend_llist *l, void *element); ZEND_API void zend_llist_del_element(zend_llist *l, void *element); ZEND_API void zend_llist_destroy(zend_llist *l); +ZEND_API void zend_llist_clean(zend_llist *l); ZEND_API void zend_llist_remove_tail(zend_llist *l); ZEND_API void zend_llist_copy(zend_llist *dst, zend_llist *src); ZEND_API void zend_llist_apply(zend_llist *l, void (*func)(void *data)); |
