mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-26 18:35:42 +00:00
Use ZEND_HASH_FOEACH_* instead of zend_hash_apply_*
This commit is contained in:
1 parent
e9f4d822b0
commit
f71da39210
4 files changed
+43
-63
No files matched your search
+2
-4
@@ -664,12 +664,10 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC);
|
||||
ZEND_API void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size TSRMLS_DC);
|
||||
ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC);
|
||||
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC);
|
||||
ZEND_API int zend_cleanup_class_data(zval *zv TSRMLS_DC);
|
||||
ZEND_API int zend_cleanup_user_class_data(zval *zv TSRMLS_DC);
|
||||
ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC);
|
||||
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC);
|
||||
ZEND_API void zend_cleanup_internal_classes(TSRMLS_D);
|
||||
ZEND_API int zend_cleanup_function_data(zval *zv TSRMLS_DC);
|
||||
ZEND_API int zend_cleanup_function_data_full(zval *zv TSRMLS_DC);
|
||||
ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array);
|
||||
|
||||
ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC);
|
||||
ZEND_API void zend_function_dtor(zval *zv);
|
||||
|
||||
+27
-4
@@ -245,6 +245,9 @@ void shutdown_destructors(TSRMLS_D) /* {{{ */
|
||||
|
||||
void shutdown_executor(TSRMLS_D) /* {{{ */
|
||||
{
|
||||
zend_function *func;
|
||||
zend_class_entry *ce;
|
||||
|
||||
zend_try {
|
||||
|
||||
/* Removed because this can not be safely done, e.g. in this situation:
|
||||
@@ -303,11 +306,31 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
|
||||
* Note that only run-time accessed data need to be cleaned up, pre-defined data can
|
||||
* not contain objects and thus are not probelmatic */
|
||||
if (EG(full_tables_cleanup)) {
|
||||
zend_hash_apply(EG(function_table), zend_cleanup_function_data_full TSRMLS_CC);
|
||||
zend_hash_apply(EG(class_table), zend_cleanup_class_data TSRMLS_CC);
|
||||
ZEND_HASH_FOREACH_PTR(EG(function_table), func) {
|
||||
if (func->type == ZEND_USER_FUNCTION) {
|
||||
zend_cleanup_op_array_data((zend_op_array *) func);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {
|
||||
if (ce->type == ZEND_USER_CLASS) {
|
||||
zend_cleanup_user_class_data(ce TSRMLS_CC);
|
||||
} else {
|
||||
zend_cleanup_internal_class_data(ce TSRMLS_CC);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
} else {
|
||||
zend_hash_reverse_apply(EG(function_table), zend_cleanup_function_data TSRMLS_CC);
|
||||
zend_hash_reverse_apply(EG(class_table), zend_cleanup_user_class_data TSRMLS_CC);
|
||||
ZEND_HASH_REVERSE_FOREACH_PTR(EG(function_table), func) {
|
||||
if (func->type != ZEND_USER_FUNCTION) {
|
||||
break;
|
||||
}
|
||||
zend_cleanup_op_array_data((zend_op_array *) func);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
ZEND_HASH_REVERSE_FOREACH_PTR(EG(class_table), ce) {
|
||||
if (ce->type != ZEND_USER_CLASS) {
|
||||
break;
|
||||
}
|
||||
zend_cleanup_user_class_data(ce TSRMLS_CC);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
zend_cleanup_internal_classes(TSRMLS_C);
|
||||
}
|
||||
} zend_end_try();
|
||||
|
||||
@@ -596,6 +596,10 @@ static inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht, HashPositio
|
||||
ZEND_HASH_REVERSE_FOREACH(ht, 0); \
|
||||
_val = _z;
|
||||
|
||||
#define ZEND_HASH_REVERSE_FOREACH_PTR(ht, _ptr) \
|
||||
ZEND_HASH_REVERSE_FOREACH(ht, 0); \
|
||||
_ptr = Z_PTR_P(_z);
|
||||
|
||||
#define ZEND_HASH_REVERSE_FOREACH_VAL_IND(ht, _val) \
|
||||
ZEND_HASH_REVERSE_FOREACH(ht, 1); \
|
||||
_val = _z;
|
||||
|
||||
+10
-55
@@ -132,42 +132,26 @@ ZEND_API void zend_function_dtor(zval *zv)
|
||||
pefree(function, function->type == ZEND_INTERNAL_FUNCTION);
|
||||
}
|
||||
|
||||
static void zend_cleanup_op_array_data(zend_op_array *op_array)
|
||||
ZEND_API void zend_cleanup_op_array_data(zend_op_array *op_array)
|
||||
{
|
||||
if (op_array->static_variables) {
|
||||
zend_hash_clean(op_array->static_variables);
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API int zend_cleanup_function_data(zval *zv TSRMLS_DC)
|
||||
{
|
||||
zend_function *function = Z_PTR_P(zv);
|
||||
|
||||
if (function->type == ZEND_USER_FUNCTION) {
|
||||
zend_cleanup_op_array_data((zend_op_array *) function);
|
||||
return ZEND_HASH_APPLY_KEEP;
|
||||
} else {
|
||||
return ZEND_HASH_APPLY_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API int zend_cleanup_function_data_full(zval *zv TSRMLS_DC)
|
||||
{
|
||||
zend_function *function = Z_PTR_P(zv);
|
||||
|
||||
if (function->type == ZEND_USER_FUNCTION) {
|
||||
zend_cleanup_op_array_data((zend_op_array *) function);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
ZEND_API void zend_cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
/* Clean all parts that can contain run-time data */
|
||||
/* Note that only run-time accessed data need to be cleaned up, pre-defined data can
|
||||
not contain objects and thus are not probelmatic */
|
||||
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
|
||||
zend_hash_apply(&ce->function_table, zend_cleanup_function_data_full TSRMLS_CC);
|
||||
zend_function *func;
|
||||
|
||||
ZEND_HASH_FOREACH_PTR(&ce->function_table, func) {
|
||||
if (func->type == ZEND_USER_FUNCTION) {
|
||||
zend_cleanup_op_array_data((zend_op_array *) func);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
if (ce->static_members_table) {
|
||||
int i;
|
||||
@@ -185,7 +169,7 @@ static inline void cleanup_user_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
if (CE_STATIC_MEMBERS(ce)) {
|
||||
int i;
|
||||
@@ -202,35 +186,6 @@ static inline void cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce TSRMLS_DC)
|
||||
{
|
||||
cleanup_internal_class_data(ce TSRMLS_CC);
|
||||
}
|
||||
|
||||
ZEND_API int zend_cleanup_user_class_data(zval *zv TSRMLS_DC)
|
||||
{
|
||||
zend_class_entry *ce = Z_PTR_P(zv);
|
||||
|
||||
if (ce->type == ZEND_USER_CLASS) {
|
||||
cleanup_user_class_data(ce TSRMLS_CC);
|
||||
return ZEND_HASH_APPLY_KEEP;
|
||||
} else {
|
||||
return ZEND_HASH_APPLY_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API int zend_cleanup_class_data(zval *zv TSRMLS_DC)
|
||||
{
|
||||
zend_class_entry *ce = Z_PTR_P(zv);
|
||||
|
||||
if (ce->type == ZEND_USER_CLASS) {
|
||||
cleanup_user_class_data(ce TSRMLS_CC);
|
||||
} else {
|
||||
cleanup_internal_class_data(ce TSRMLS_CC);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _destroy_zend_class_traits_info(zend_class_entry *ce)
|
||||
{
|
||||
if (ce->num_traits > 0 && ce->traits) {
|
||||
|
||||
Reference in new issue
Block a user