Permalink
Browse files

MFZE1: make sure the resource-list is always consistent during shutdo…

…wn (Thies).
  • Loading branch information...
1 parent 2697ce6 commit bf5bb8427734100e897e64ec21f1a6ee31a15219 @sebastianbergmann sebastianbergmann committed Apr 19, 2002
Showing with 19 additions and 24 deletions.
  1. +17 −0 Zend/zend_hash.c
  2. +1 −0 Zend/zend_hash.h
  3. +1 −24 Zend/zend_list.c
View
@@ -653,6 +653,23 @@ ZEND_API void zend_hash_graceful_destroy(HashTable *ht)
SET_INCONSISTENT(HT_DESTROYED);
}
+ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)
+{
+ Bucket *p;
+
+ IS_CONSISTENT(ht);
+
+ p = ht->pListTail;
+ while (p != NULL) {
+ zend_hash_apply_deleter(ht, p);
+ p = ht->pListTail;
+ }
+
+ pefree(ht->arBuckets, ht->persistent);
+
+ SET_INCONSISTENT(HT_DESTROYED);
+}
+
/* This is used to selectively delete certain entries from a hashtable.
* destruct() receives the data and decides if the entry should be deleted
* or not
View
@@ -119,6 +119,7 @@ typedef int (*apply_func_arg_t)(void *pDest, void *argument TSRMLS_DC);
typedef int (*apply_func_args_t)(void *pDest, int num_args, va_list args, zend_hash_key *hash_key);
ZEND_API void zend_hash_graceful_destroy(HashTable *ht);
+ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht);
ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func TSRMLS_DC);
ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC);
ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);
View
@@ -230,30 +230,7 @@ int zend_init_rsrc_plist(TSRMLS_D)
void zend_destroy_rsrc_list(HashTable *ht TSRMLS_DC)
{
- Bucket *p, *q;
-
- while (1) {
- p = ht->pListTail;
- if (!p) {
- break;
- }
- q = p->pListLast;
- if (q) {
- q->pListNext = NULL;
- }
- ht->pListTail = q;
-
- if (ht->pDestructor) {
- zend_try {
- ht->pDestructor(p->pData);
- } zend_end_try();
- }
- if (!p->pDataPtr && p->pData) {
- pefree(p->pData, ht->persistent);
- }
- pefree(p, ht->persistent);
- }
- pefree(ht->arBuckets, ht->persistent);
+ zend_hash_graceful_reverse_destroy(ht);
}

0 comments on commit bf5bb84

Please sign in to comment.