diff options
| author | Nikita Popov <nikic@php.net> | 2012-05-28 06:43:18 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2012-05-28 06:43:18 +0200 |
| commit | 4aab08b64c2318775be6d8e629747ac66a108485 (patch) | |
| tree | 72430859b106048ca4e8732f67055f15909b3928 /Zend/zend_execute.c | |
| parent | bcc7d976f31a572160a52c15f415deea3497ab68 (diff) | |
| download | php-git-4aab08b64c2318775be6d8e629747ac66a108485.tar.gz | |
Properly free resources when generator return value not used
To keep things clean two new functions are introduced:
zend_clean_and_cache_symbol_table(HashTable *symbol_table)
zend_free_compiled_variables(zval ***CVs, int num)
Diffstat (limited to 'Zend/zend_execute.c')
| -rw-r--r-- | Zend/zend_execute.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index d82abfc613..9031fb5557 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1538,6 +1538,31 @@ ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const t return get_zval_ptr_ptr(op_type, node, Ts, should_free, type); } +void zend_clean_and_cache_symbol_table(HashTable *symbol_table) /* {{{ */ +{ + if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) { + zend_hash_destroy(symbol_table); + FREE_HASHTABLE(symbol_table); + } else { + /* clean before putting into the cache, since clean + could call dtors, which could use cached hash */ + zend_hash_clean(symbol_table); + *(++EG(symtable_cache_ptr)) = symbol_table; + } +} +/* }}} */ + +void zend_free_compiled_variables(zval ***CVs, int num) /* {{{ */ +{ + int i; + for (i = 0; i < num; ++i) { + if (CVs[i]) { + zval_ptr_dtor(CVs[i]); + } + } +} +/* }}} */ + /* * Local variables: * tab-width: 4 |
