diff options
| author | Andi Gutmans <andi@php.net> | 1999-05-05 19:24:46 +0000 |
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 1999-05-05 19:24:46 +0000 |
| commit | c8b2bf0a1d57e5c244ddd477255a2a5c662b8e58 (patch) | |
| tree | f0a59f48487b5d82dd67cc4535e59f09509e5d42 | |
| parent | 537cc54acd4844624e60ed9f128155b35374b4a6 (diff) | |
| download | php-git-c8b2bf0a1d57e5c244ddd477255a2a5c662b8e58.tar.gz | |
llist improvements
| -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)); |
