diff options
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 70 |
1 files changed, 21 insertions, 49 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index f16d07b004..7d79d99bee 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1119,13 +1119,10 @@ static int zval_update_class_constant(zval *pp, int is_static, int offset TSRMLS if ((*scope)->parent) { zend_class_entry *ce = *scope; - HashPosition pos; zend_property_info *prop_info; do { - for (zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos); - (prop_info = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL; - zend_hash_move_forward_ex(&ce->properties_info, &pos)) { + ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) { if (is_static == ((prop_info->flags & ZEND_ACC_STATIC) != 0) && offset == prop_info->offset) { int ret; @@ -1135,7 +1132,7 @@ static int zval_update_class_constant(zval *pp, int is_static, int offset TSRMLS *scope = old_scope; return ret; } - } + } ZEND_HASH_FOREACH_END(); ce = ce->parent; } while (ce); @@ -1223,17 +1220,12 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti { object->properties = properties; if (object->ce->default_properties_count) { - HashPosition pos; zval *prop, tmp; zend_string *key; ulong num_key; zend_property_info *property_info; - for (zend_hash_internal_pointer_reset_ex(properties, &pos); - (prop = zend_hash_get_current_data_ex(properties, &pos)) != NULL && - zend_hash_get_current_key_ex(properties, &key, &num_key, 0, &pos) == HASH_KEY_IS_STRING; - zend_hash_move_forward_ex(properties, &pos)) { - + ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, prop) { ZVAL_STR(&tmp, key); property_info = zend_get_property_info(object->ce, &tmp, 1 TSRMLS_CC); if (property_info && @@ -1242,24 +1234,19 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); ZVAL_INDIRECT(prop, &object->properties_table[property_info->offset]); } - } + } ZEND_HASH_FOREACH_END(); } } /* }}} */ ZEND_API void object_properties_load(zend_object *object, HashTable *properties TSRMLS_DC) /* {{{ */ { - HashPosition pos; zval *prop, tmp; zend_string *key; ulong num_key; zend_property_info *property_info; - for (zend_hash_internal_pointer_reset_ex(properties, &pos); - (prop = zend_hash_get_current_data_ex(properties, &pos)) != NULL && - zend_hash_get_current_key_ex(properties, &key, &num_key, 0, &pos) == HASH_KEY_IS_STRING; - zend_hash_move_forward_ex(properties, &pos)) { - + ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, prop) { ZVAL_STR(&tmp, key); property_info = zend_get_property_info(object->ce, &tmp, 1 TSRMLS_CC); if (property_info && @@ -1279,7 +1266,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties prop = zend_hash_update(object->properties, key, prop); zval_add_ref(prop); } - } + } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -1892,7 +1879,6 @@ try_again: ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */ { - HashPosition pos; zend_module_entry *module; int startup_count = 0; int shutdown_count = 0; @@ -1901,9 +1887,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */ int class_count = 0; /* Collect extensions with request startup/shutdown handlers */ - for (zend_hash_internal_pointer_reset_ex(&module_registry, &pos); - (module = zend_hash_get_current_data_ptr_ex(&module_registry, &pos)) != NULL; - zend_hash_move_forward_ex(&module_registry, &pos)) { + ZEND_HASH_FOREACH_PTR(&module_registry, module) { if (module->request_startup_func) { startup_count++; } @@ -1913,7 +1897,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */ if (module->post_deactivate_func) { post_deactivate_count++; } - } + } ZEND_HASH_FOREACH_END(); module_request_startup_handlers = (zend_module_entry**)malloc( sizeof(zend_module_entry*) * (startup_count + 1 + @@ -1926,9 +1910,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */ module_post_deactivate_handlers[post_deactivate_count] = NULL; startup_count = 0; - for (zend_hash_internal_pointer_reset_ex(&module_registry, &pos); - (module = zend_hash_get_current_data_ptr_ex(&module_registry, &pos)) != NULL; - zend_hash_move_forward_ex(&module_registry, &pos)) { + ZEND_HASH_FOREACH_PTR(&module_registry, module) { if (module->request_startup_func) { module_request_startup_handlers[startup_count++] = module; } @@ -1938,17 +1920,15 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */ if (module->post_deactivate_func) { module_post_deactivate_handlers[--post_deactivate_count] = module; } - } + } ZEND_HASH_FOREACH_END(); /* Collect internal classes with static members */ - for (zend_hash_internal_pointer_reset_ex(CG(class_table), &pos); - (ce = zend_hash_get_current_data_ptr_ex(CG(class_table), &pos)) != NULL; - zend_hash_move_forward_ex(CG(class_table), &pos)) { + ZEND_HASH_FOREACH_PTR(CG(class_table), ce) { if (ce->type == ZEND_INTERNAL_CLASS && ce->default_static_members_count > 0) { class_count++; } - } + } ZEND_HASH_FOREACH_END(); class_cleanup_handlers = (zend_class_entry**)malloc( sizeof(zend_class_entry*) * @@ -1956,14 +1936,12 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */ class_cleanup_handlers[class_count] = NULL; if (class_count) { - for (zend_hash_internal_pointer_reset_ex(CG(class_table), &pos); - (ce = zend_hash_get_current_data_ptr_ex(CG(class_table), &pos)) != NULL; - zend_hash_move_forward_ex(CG(class_table), &pos)) { + ZEND_HASH_FOREACH_PTR(CG(class_table), ce) { if (ce->type == ZEND_INTERNAL_CLASS && ce->default_static_members_count > 0) { class_cleanup_handlers[--class_count] = ce; } - } + } ZEND_HASH_FOREACH_END(); } } /* }}} */ @@ -3407,7 +3385,6 @@ ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) /* {{{ */ { - HashPosition pos; zval *arg, *params; zend_fcall_info_args_clear(fci, !args); @@ -3423,12 +3400,10 @@ ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) /* fci->param_count = zend_hash_num_elements(Z_ARRVAL_P(args)); fci->params = params = (zval *) erealloc(fci->params, fci->param_count * sizeof(zval)); - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos); - while ((arg = zend_hash_get_current_data_ex(Z_ARRVAL_P(args), &pos)) != NULL) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args), arg) { ZVAL_COPY(params, arg); params++; - zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos); - } + } ZEND_HASH_FOREACH_END(); return SUCCESS; } @@ -4026,6 +4001,8 @@ ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_functi zend_function *func; HashPosition iterator; HashTable *function_table; + zend_string *name; + ulong idx; if (f->common.type != ZEND_USER_FUNCTION || *(f->op_array.refcount) < 2 || @@ -4035,13 +4012,9 @@ ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_functi } function_table = &ce->function_table; - zend_hash_internal_pointer_reset_ex(function_table, &iterator); - while ((func = zend_hash_get_current_data_ptr_ex(function_table, &iterator)) != NULL) { + ZEND_HASH_FOREACH_KEY_PTR(function_table, idx, name, func) { if (func == f) { - zend_string *name; - ulong idx; - - if (zend_hash_get_current_key_ex(function_table, &name, &idx, 0, &iterator) != HASH_KEY_IS_STRING) { + if (!name) { return f->common.function_name; } if (name->len == f->common.function_name->len && @@ -4050,8 +4023,7 @@ ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_functi } return zend_find_alias_name(f->common.scope, name); } - zend_hash_move_forward_ex(function_table, &iterator); - } + } ZEND_HASH_FOREACH_END(); return f->common.function_name; } /* }}} */ |