diff options
40 files changed, 158 insertions, 260 deletions
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 0772009bbe..f505483562 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -9,6 +9,7 @@ PHP 7.2 INTERNALS UPGRADE NOTES f. zend_arg_info.class_name removed g. ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX changed h. valid_symbol_table removed + i. array_init() and array_init_size() 2. Build system changes a. Unix build system changes @@ -48,6 +49,9 @@ PHP 7.2 INTERNALS UPGRADE NOTES h. valid_symbol_table is removed from executor_globals. Use EG(active) instead of removed EG(valid_symbol_table) + i. array_init() and array_init_size() are not functions anymore. + They don't return any values. + ======================== 2. Build system changes ======================== diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 7c82d6ec25..45999da33c 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1084,15 +1084,6 @@ ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this } /* }}} */ -/* Argument parsing API -- andrei */ -ZEND_API int _array_init(zval *arg, uint32_t size ZEND_FILE_LINE_DC) /* {{{ */ -{ - ZVAL_NEW_ARR(arg); - _zend_hash_init(Z_ARRVAL_P(arg), size, ZVAL_PTR_DTOR, 0 ZEND_FILE_LINE_RELAY_CC); - return SUCCESS; -} -/* }}} */ - /* This function should be called after the constructor has been called * because it may call __set from the uninitialized object otherwise. */ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 1d4851983c..c3220d2685 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -390,12 +390,11 @@ ZEND_API char *zend_get_type_by_const(int type); #define DLEXPORT #endif -#define array_init(arg) _array_init((arg), 0 ZEND_FILE_LINE_CC) -#define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC) +#define array_init(arg) ZVAL_ARR((arg), zend_new_array(0)) +#define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size)) #define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC) #define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC) #define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC) -ZEND_API int _array_init(zval *arg, uint32_t size ZEND_FILE_LINE_DC); ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC); ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC); ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC); diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 2e4e103fb5..c3c2ae3b3a 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -503,8 +503,7 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp) /* {{{ *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) { HashTable *static_variables = closure->func.op_array.static_variables; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 0772bc4f1e..7813df3968 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3711,9 +3711,8 @@ static int zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ zend_bool ok = 1; zval *val, tmp; HashTable *src = Z_ARRVAL(array.u.constant); - HashTable *dst = emalloc(sizeof(HashTable)); + HashTable *dst = zend_new_array(zend_hash_num_elements(src)); - zend_hash_init(dst, zend_hash_num_elements(src), NULL, ZVAL_PTR_DTOR, 0); ZVAL_TRUE(&tmp); if (strict) { @@ -4239,8 +4238,7 @@ static void zend_compile_static_var_common(zend_ast *var_ast, zval *value, zend_ if (CG(active_op_array)->scope) { CG(active_op_array)->scope->ce_flags |= ZEND_HAS_STATIC_IN_METHODS; } - ALLOC_HASHTABLE(CG(active_op_array)->static_variables); - zend_hash_init(CG(active_op_array)->static_variables, 8, NULL, ZVAL_PTR_DTOR, 0); + CG(active_op_array)->static_variables = zend_new_array(8); } if (GC_REFCOUNT(CG(active_op_array)->static_variables) > 1) { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 5a32604440..a4bdf03b21 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1698,8 +1698,7 @@ fetch_from_array: } if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) { if (type != BP_VAR_UNSET) { - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + array_init(container); goto fetch_from_array; } else { /* for read-mode only */ diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index a619b3ccf3..cd81eedbdd 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1527,8 +1527,7 @@ ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */ } zend_hash_extend(symbol_table, ex->func->op_array.last_var, 0); } else { - symbol_table = ex->symbol_table = emalloc(sizeof(zend_array)); - zend_hash_init(symbol_table, ex->func->op_array.last_var, NULL, ZVAL_PTR_DTOR, 0); + symbol_table = ex->symbol_table = zend_new_array(ex->func->op_array.last_var); if (!ex->func->op_array.last_var) { return symbol_table; } diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 3d5f584056..5f03ce86b0 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -170,11 +170,11 @@ static zend_always_inline void zend_hash_check_init(HashTable *ht, int packed) static const uint32_t uninitialized_bucket[-HT_MIN_MASK] = {HT_INVALID_IDX, HT_INVALID_IDX}; -ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) +static zend_always_inline void _zend_hash_init_int(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection) { GC_REFCOUNT(ht) = 1; GC_TYPE_INFO(ht) = IS_ARRAY | (persistent ? 0 : (GC_COLLECTABLE << GC_FLAGS_SHIFT)); - ht->u.flags = (persistent ? HASH_FLAG_PERSISTENT : 0) | HASH_FLAG_APPLY_PROTECTION | HASH_FLAG_STATIC_KEYS; + ht->u.flags = (persistent ? HASH_FLAG_PERSISTENT : 0) | (bApplyProtection ? HASH_FLAG_APPLY_PROTECTION : 0) | HASH_FLAG_STATIC_KEYS; ht->nTableMask = HT_MIN_MASK; HT_SET_DATA_ADDR(ht, &uninitialized_bucket); ht->nNumUsed = 0; @@ -185,6 +185,18 @@ ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_ ht->nTableSize = zend_hash_check_size(nSize); } +ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent) +{ + _zend_hash_init_int(ht, nSize, pDestructor, persistent, 1); +} + +ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t nSize ZEND_FILE_LINE_DC) +{ + HashTable *ht = emalloc(sizeof(HashTable)); + _zend_hash_init_int(ht, nSize, ZVAL_PTR_DTOR, 0, 1); + return ht; +} + static void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht) { HT_ASSERT_RC1(ht); @@ -233,12 +245,9 @@ ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht) pefree(old_data, (ht)->u.flags & HASH_FLAG_PERSISTENT); } -ZEND_API void ZEND_FASTCALL _zend_hash_init_ex(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) +ZEND_API void ZEND_FASTCALL _zend_hash_init_ex(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection) { - _zend_hash_init(ht, nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); - if (!bApplyProtection) { - ht->u.flags &= ~HASH_FLAG_APPLY_PROTECTION; - } + _zend_hash_init_int(ht, nSize, pDestructor, persistent, bApplyProtection); } ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, zend_bool packed) @@ -2507,9 +2516,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht) convert: { - HashTable *new_ht = emalloc(sizeof(HashTable)); - - zend_hash_init(new_ht, zend_hash_num_elements(ht), NULL, ZVAL_PTR_DTOR, 0); + HashTable *new_ht = zend_new_array(zend_hash_num_elements(ht)); ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) { if (!str_key) { @@ -2567,9 +2574,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, zend convert: { - HashTable *new_ht = emalloc(sizeof(HashTable)); - - zend_hash_init(new_ht, zend_hash_num_elements(ht), NULL, ZVAL_PTR_DTOR, 0); + HashTable *new_ht = zend_new_array(zend_hash_num_elements(ht)); ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) { do { diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index fc91dfb8c9..e362b5557b 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -68,12 +68,15 @@ typedef zend_bool (*merge_checker_func_t)(HashTable *target_ht, zval *source_dat BEGIN_EXTERN_C() /* startup/shutdown */ -ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC); -ZEND_API void ZEND_FASTCALL _zend_hash_init_ex(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC); +ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent); +ZEND_API void ZEND_FASTCALL _zend_hash_init_ex(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection); ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht); ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht); -#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) _zend_hash_init((ht), (nSize), (pDestructor), (persistent) ZEND_FILE_LINE_CC) -#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) _zend_hash_init_ex((ht), (nSize), (pDestructor), (persistent), (bApplyProtection) ZEND_FILE_LINE_CC) + +#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \ + _zend_hash_init((ht), (nSize), (pDestructor), (persistent)) +#define zend_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \ + _zend_hash_init_ex((ht), (nSize), (pDestructor), (persistent), (bApplyProtection)) ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, zend_bool packed); ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht); @@ -250,6 +253,10 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_ ZEND_API int ZEND_FASTCALL zend_hash_rehash(HashTable *ht); +#define zend_new_array(size) \ + _zend_new_array(size ZEND_FILE_LINE_CC) + +ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t size ZEND_FILE_LINE_DC); ZEND_API uint32_t zend_array_count(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(HashTable *source); ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht); diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 21a366016f..a11664ff0e 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -79,8 +79,7 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ zend_property_info *prop_info; zend_class_entry *ce = zobj->ce; - ALLOC_HASHTABLE(zobj->properties); - zend_hash_init(zobj->properties, ce->default_properties_count, NULL, ZVAL_PTR_DTOR, 0); + zobj->properties = zend_new_array(ce->default_properties_count); if (ce->default_properties_count) { zend_hash_real_init(zobj->properties, 0); zobj->properties->nInternalPointer = 0; @@ -180,8 +179,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ * } } else if (Z_TYPE(retval) == IS_NULL) { *is_temp = 1; - ALLOC_HASHTABLE(ht); - zend_hash_init(ht, 0, NULL, ZVAL_PTR_DTOR, 0); + ht = zend_new_array(0); return ht; } diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index d5c375f6ed..123e5db238 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -197,8 +197,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o zend_string *key; if (!new_object->properties) { - ALLOC_HASHTABLE(new_object->properties); - zend_hash_init(new_object->properties, zend_hash_num_elements(old_object->properties), NULL, ZVAL_PTR_DTOR, 0); + new_object->properties = zend_new_array(zend_hash_num_elements(old_object->properties)); zend_hash_real_init(new_object->properties, 0); } else { zend_hash_extend(new_object->properties, new_object->properties->nNumUsed + zend_hash_num_elements(old_object->properties), 0); diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 200857558e..e14ad11f00 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -581,8 +581,7 @@ static void convert_scalar_to_array(zval *op) /* {{{ */ ZVAL_COPY_VALUE(&entry, op); - ZVAL_NEW_ARR(op); - zend_hash_init(Z_ARRVAL_P(op), 8, NULL, ZVAL_PTR_DTOR, 0); + array_init_size(op, 1); zend_hash_index_add_new(Z_ARRVAL_P(op), 0, &entry); } /* }}} */ @@ -632,8 +631,7 @@ try_again: } break; case IS_NULL: - ZVAL_NEW_ARR(op); - zend_hash_init(Z_ARRVAL_P(op), 8, NULL, ZVAL_PTR_DTOR, 0); + array_init(op); break; case IS_REFERENCE: zend_unwrap_reference(op); diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index fab54672fc..66af862884 100644 --- a/Zend/zend_ts_hash.c +++ b/Zend/zend_ts_hash.c @@ -59,24 +59,24 @@ static void end_write(TsHashTable *ht) } /* delegates */ -ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) +ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif - _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); + _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent); } -ZEND_API void _zend_ts_hash_init_ex(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) +ZEND_API void _zend_ts_hash_init_ex(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif - _zend_hash_init_ex(TS_HASH(ht), nSize, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_RELAY_CC); + _zend_hash_init_ex(TS_HASH(ht), nSize, pDestructor, persistent, bApplyProtection); } ZEND_API void zend_ts_hash_destroy(TsHashTable *ht) diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index 18421e58f6..3128096cd3 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -37,15 +37,15 @@ BEGIN_EXTERN_C() #define TS_HASH(table) (&(table->hash)) /* startup/shutdown */ -ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC); -ZEND_API void _zend_ts_hash_init_ex(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC); +ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent); +ZEND_API void _zend_ts_hash_init_ex(TsHashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection); ZEND_API void zend_ts_hash_destroy(TsHashTable *ht); ZEND_API void zend_ts_hash_clean(TsHashTable *ht); #define zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \ - _zend_ts_hash_init(ht, nSize, pDestructor, persistent ZEND_FILE_LINE_CC) + _zend_ts_hash_init(ht, nSize, pDestructor, persistent) #define zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \ - _zend_ts_hash_init_ex(ht, nSize, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_CC) + _zend_ts_hash_init_ex(ht, nSize, pDestructor, persistent, bApplyProtection) /* additions/updates/changes */ diff --git a/Zend/zend_types.h b/Zend/zend_types.h index b78ed0c45a..1028978c28 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -721,8 +721,9 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) { } while (0) #define ZVAL_ARR(z, a) do { \ + zend_array *__arr = (a); \ zval *__z = (z); \ - Z_ARR_P(__z) = (a); \ + Z_ARR_P(__z) = __arr; \ Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \ } while (0) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 22f13feba4..489ac6541a 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -900,8 +900,7 @@ ZEND_VM_C_LABEL(assign_dim_op_new_array): } else if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); ZEND_VM_C_LABEL(assign_dim_op_convert_to_array): - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); ZEND_VM_C_GOTO(assign_dim_op_new_array); } @@ -2247,8 +2246,7 @@ ZEND_VM_C_LABEL(try_assign_dim_array): FREE_OP_DATA(); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); ZEND_VM_C_GOTO(try_assign_dim_array); } else { if (OP1_TYPE != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -5219,8 +5217,7 @@ ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUSED|NEXT| } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (OP1_TYPE != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -5277,8 +5274,7 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE) if (opline->extended_value == IS_ARRAY) { if (Z_TYPE_P(expr) != IS_OBJECT) { - ZVAL_NEW_ARR(result); - zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(result, zend_new_array(8)); if (Z_TYPE_P(expr) != IS_NULL) { expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr); if (OP1_TYPE == IS_CONST) { @@ -7774,8 +7770,7 @@ ZEND_VM_HANDLER(158, ZEND_CALL_TRAMPOLINE, ANY, ANY) SAVE_OPLINE(); - args = emalloc(sizeof(zend_array)); - zend_hash_init(args, num_args, NULL, ZVAL_PTR_DTOR, 0); + args = zend_new_array(num_args); if (num_args) { zval *p = ZEND_CALL_ARG(execute_data, 1); zval *end = p + num_args; @@ -8270,8 +8265,7 @@ ZEND_VM_HANDLER(195, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED) result_size = arg_count; } - ht = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(ht, result_size, NULL, ZVAL_PTR_DTOR, 0); + ht = zend_new_array(result_size); ZVAL_ARR(EX_VAR(opline->result.var), ht); if (result_size) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index a6a483c23d..f26b6c5c92 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1965,8 +1965,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z SAVE_OPLINE(); - args = emalloc(sizeof(zend_array)); - zend_hash_init(args, num_args, NULL, ZVAL_PTR_DTOR, 0); + args = zend_new_array(num_args); if (num_args) { zval *p = ZEND_CALL_ARG(execute_data, 1); zval *end = p + num_args; @@ -3392,8 +3391,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CONST_HANDLER(ZEND_O if (opline->extended_value == IS_ARRAY) { if (Z_TYPE_P(expr) != IS_OBJECT) { - ZVAL_NEW_ARR(result); - zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(result, zend_new_array(8)); if (Z_TYPE_P(expr) != IS_NULL) { expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr); if (IS_CONST == IS_CONST) { @@ -5887,8 +5885,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CONST_HA } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CONST != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -7671,8 +7668,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_UNUSED_H } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CONST != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -8173,8 +8169,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_CONST_UNUSE result_size = arg_count; } - ht = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(ht, result_size, NULL, ZVAL_PTR_DTOR, 0); + ht = zend_new_array(result_size); ZVAL_ARR(EX_VAR(opline->result.var), ht); if (result_size) { @@ -9906,8 +9901,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_CV_HANDL } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CONST != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -11874,8 +11868,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_TMPVAR_H } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CONST != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -12897,8 +12890,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPC if (opline->extended_value == IS_ARRAY) { if (Z_TYPE_P(expr) != IS_OBJECT) { - ZVAL_NEW_ARR(result); - zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(result, zend_new_array(8)); if (Z_TYPE_P(expr) != IS_NULL) { expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr); if (IS_TMP_VAR == IS_CONST) { @@ -13821,8 +13813,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CONST_HAND } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_TMP_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -14550,8 +14541,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_UNUSED_HAN } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_TMP_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -15173,8 +15163,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_CV_HANDLER } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_TMP_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -15696,8 +15685,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_TMP_TMPVAR_HAN } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_TMP_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -16549,8 +16537,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPC if (opline->extended_value == IS_ARRAY) { if (Z_TYPE_P(expr) != IS_OBJECT) { - ZVAL_NEW_ARR(result); - zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(result, zend_new_array(8)); if (Z_TYPE_P(expr) != IS_NULL) { expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr); if (IS_VAR == IS_CONST) { @@ -17648,8 +17635,7 @@ assign_dim_op_new_array: } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -19082,8 +19068,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -19175,8 +19160,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -19268,8 +19252,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -19360,8 +19343,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -19786,8 +19768,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_CONST_HAND } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -20672,8 +20653,7 @@ assign_dim_op_new_array: } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -20935,8 +20915,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -21028,8 +21007,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -21121,8 +21099,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -21213,8 +21190,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -21548,8 +21524,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_UNUSED_HAN } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -21986,8 +21961,7 @@ assign_dim_op_new_array: } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -23420,8 +23394,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -23513,8 +23486,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -23606,8 +23578,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -23698,8 +23669,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -24096,8 +24066,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_CV_HANDLER } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -24592,8 +24561,7 @@ assign_dim_op_new_array: } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -26031,8 +25999,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -26124,8 +26091,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -26217,8 +26183,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -26309,8 +26274,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_VAR != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -26594,8 +26558,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_VAR_TMPVAR_HAN } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_VAR != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -29472,8 +29435,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_UNUSED_UNUS result_size = arg_count; } - ht = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(ht, result_size, NULL, ZVAL_PTR_DTOR, 0); + ht = zend_new_array(result_size); ZVAL_ARR(EX_VAR(opline->result.var), ht); if (result_size) { @@ -33819,8 +33781,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCO if (opline->extended_value == IS_ARRAY) { if (Z_TYPE_P(expr) != IS_OBJECT) { - ZVAL_NEW_ARR(result); - zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(result, zend_new_array(8)); if (Z_TYPE_P(expr) != IS_NULL) { expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr); if (IS_CV == IS_CONST) { @@ -35387,8 +35348,7 @@ assign_dim_op_new_array: } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -37021,8 +36981,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -37114,8 +37073,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -37207,8 +37165,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -37299,8 +37256,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -37787,8 +37743,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CONST_HANDL } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CV != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -39545,8 +39500,7 @@ assign_dim_op_new_array: } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -40037,8 +39991,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -40130,8 +40083,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -40223,8 +40175,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -40315,8 +40266,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -40495,8 +40445,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_UNUSED_HAND } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CV != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -41904,8 +41853,7 @@ assign_dim_op_new_array: } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -43471,8 +43419,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -43564,8 +43511,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -43657,8 +43603,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -43749,8 +43694,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -44293,8 +44237,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_CV_HANDLER( } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CV != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ @@ -45578,8 +45521,7 @@ assign_dim_op_new_array: } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) { container = GET_OP1_UNDEF_CV(container, BP_VAR_RW); assign_dim_op_convert_to_array: - ZVAL_NEW_ARR(container); - zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(container, zend_new_array(8)); goto assign_dim_op_new_array; } @@ -47151,8 +47093,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -47244,8 +47185,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -47337,8 +47277,7 @@ try_assign_dim_array: zval_ptr_dtor_nogc(free_op_data); } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -47429,8 +47368,7 @@ try_assign_dim_array: } } else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) { - ZVAL_NEW_ARR(object_ptr); - zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(object_ptr, zend_new_array(8)); goto try_assign_dim_array; } else { if (IS_CV != IS_VAR || EXPECTED(!Z_ISERROR_P(object_ptr))) { @@ -47862,8 +47800,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CV_TMPVAR_HAND } else { size = 0; } - ZVAL_NEW_ARR(array); - zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0); + ZVAL_ARR(array, zend_new_array(size)); if (IS_CV != IS_UNUSED) { /* Explicitly initialize array as not-packed if flag is set */ diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 77f918ae9b..9892285cbb 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1105,8 +1105,7 @@ zend_object *dom_xpath_objects_new(zend_class_entry *class_type) { dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + zend_object_properties_size(class_type)); - ALLOC_HASHTABLE(intern->registered_phpfunctions); - zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->registered_phpfunctions = zend_new_array(0); intern->dom.prop_handler = &dom_xpath_prop_handlers; intern->dom.std.handlers = &dom_xpath_object_handlers; diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 068ca61bfe..57d1c8796a 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -204,8 +204,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, xmlNode *nodep; dom_object *obj; if (intern->node_list == NULL) { - ALLOC_HASHTABLE(intern->node_list); - zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->node_list = zend_new_array(0); } Z_ADDREF(retval); zend_hash_next_index_insert(intern->node_list, &retval); diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index ae9e258608..355072dec5 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -144,8 +144,7 @@ static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp) *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); bio = Z_INTL_BREAKITERATOR_P(object); biter = bio->biter; diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp index 41d8dd4926..5c67051d84 100644 --- a/ext/intl/calendar/calendar_class.cpp +++ b/ext/intl/calendar/calendar_class.cpp @@ -154,8 +154,7 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp) *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); co = Z_INTL_CALENDAR_P(object); cal = co->ucal; diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index cb74a3fb1b..bfc9dbe3ac 100644 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c @@ -41,8 +41,7 @@ static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *ret count = zend_hash_num_elements(Z_ARRVAL_P(args)); - ALLOC_HASHTABLE(args_copy); - zend_hash_init(args_copy, count, NULL, ZVAL_PTR_DTOR, 0); + args_copy = zend_new_array(count); zend_hash_copy(args_copy, Z_ARRVAL_P(args), (copy_ctor_func_t)zval_add_ref); umsg_format_helper(mfo, args_copy, &formatted, &formatted_len); diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp index b036de81cf..c6f4dd5447 100644 --- a/ext/intl/timezone/timezone_class.cpp +++ b/ext/intl/timezone/timezone_class.cpp @@ -295,8 +295,7 @@ static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp) *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); to = Z_INTL_TIMEZONE_P(object); tz = to->utimezone; diff --git a/ext/json/json_parser.tab.c b/ext/json/json_parser.tab.c index c5247e5f04..5db1842900 100644 --- a/ext/json/json_parser.tab.c +++ b/ext/json/json_parser.tab.c @@ -1856,7 +1856,8 @@ yyreturn: static int php_json_parser_array_create(php_json_parser *parser, zval *array) { - return array_init(array); + array_init(array); + return SUCCESS; } static int php_json_parser_array_append(php_json_parser *parser, zval *array, zval *zvalue) @@ -1868,7 +1869,8 @@ static int php_json_parser_array_append(php_json_parser *parser, zval *array, zv static int php_json_parser_object_create(php_json_parser *parser, zval *object) { if (parser->scanner.options & PHP_JSON_OBJECT_AS_ARRAY) { - return array_init(object); + array_init(object); + return SUCCESS; } else { return object_init(object); } diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index d88860c4f3..c355ae2ba4 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -1042,9 +1042,7 @@ static PHP_FUNCTION(libxml_get_errors) xmlErrorPtr error; - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); if (LIBXML(error_list)) { diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index e9b567edfa..0bb18e9b57 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -3134,8 +3134,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons php_error_docref(NULL, E_WARNING, "Cannot convert recursively referenced values"); return NULL; } - output = (HashTable *)emalloc(sizeof(HashTable)); - zend_hash_init(output, zend_hash_num_elements(input), NULL, ZVAL_PTR_DTOR, 0); + output = zend_new_array(zend_hash_num_elements(input)); ZEND_HASH_FOREACH_KEY_VAL(input, idx, key, entry) { /* convert key */ if (key) { @@ -3160,8 +3159,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons case IS_ARRAY: chash = php_mb_convert_encoding_recursive(HASH_OF(entry), _to_encoding, _from_encodings); if (!chash) { - chash = (HashTable *)emalloc(sizeof(HashTable)); - zend_hash_init(chash, 0, NULL, ZVAL_PTR_DTOR, 0); + chash = zend_new_array(0); } ZVAL_ARR(&entry_tmp, chash); break; diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index b77fc8dec0..63065b5e90 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -424,8 +424,7 @@ HashTable *mysqli_object_get_debug_info(zval *object, int *is_temp) HashTable *retval, *props = obj->prop_handler; mysqli_prop_handler *entry; - ALLOC_HASHTABLE(retval); - ZEND_INIT_SYMTABLE_EX(retval, zend_hash_num_elements(props) + 1, 0); + retval = zend_new_array(zend_hash_num_elements(props) + 1); ZEND_HASH_FOREACH_PTR(props, entry) { zval rv, member; diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 8ec4230848..b62b35c8b6 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -391,8 +391,7 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) zend_ulong idx; ZVAL_TRUE(&tmp); - dst = emalloc(sizeof(HashTable)); - zend_hash_init(dst, zend_hash_num_elements(src), NULL, ZVAL_PTR_DTOR, 0); + dst = zend_new_array(zend_hash_num_elements(src)); if (strict) { ZEND_HASH_FOREACH_VAL(src, val) { if (Z_TYPE_P(val) == IS_STRING) { diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 0a97711ce9..1ece45d80c 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -103,8 +103,7 @@ typedef struct _sccp_ctx { static void empty_partial_array(zval *zv) { Z_TYPE_INFO_P(zv) = PARTIAL_ARRAY | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT); - Z_ARR_P(zv) = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(Z_ARR_P(zv), 8, NULL, ZVAL_PTR_DTOR, 0); + Z_ARR_P(zv) = zend_new_array(8); } static void dup_partial_array(zval *dst, zval *src) @@ -116,8 +115,7 @@ static void dup_partial_array(zval *dst, zval *src) static void empty_partial_object(zval *zv) { Z_TYPE_INFO_P(zv) = PARTIAL_OBJECT | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT); - Z_ARR_P(zv) = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(Z_ARR_P(zv), 8, NULL, ZVAL_PTR_DTOR, 0); + Z_ARR_P(zv) = zend_new_array(8); } static void dup_partial_object(zval *dst, zval *src) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index caf3ff1ef4..d65bf217c4 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -857,8 +857,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_ case PDO_FETCH_NUM: case PDO_FETCH_NAMED: if (!return_all) { - ZVAL_NEW_ARR(return_value); - zend_hash_init(Z_ARRVAL_P(return_value), stmt->column_count, NULL, ZVAL_PTR_DTOR, 0); + array_init_size(return_value, stmt->column_count); } else { array_init(return_value); } diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 0ec2c86f4a..92d180cf8b 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1133,14 +1133,12 @@ static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */ sxe = Z_SXEOBJ_P(object); if (is_debug) { - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); + rv = zend_new_array(0); } else if (sxe->properties) { zend_hash_clean(sxe->properties); rv = sxe->properties; } else { - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); + rv = zend_new_array(0); sxe->properties = rv; } diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 13bfce90b2..21deb4ec80 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1223,8 +1223,7 @@ PHP_METHOD(SoapServer, SoapServer) service->version = version; service->type = SOAP_FUNCTIONS; service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); + service->soap_functions.ft = zend_new_array(0); if (Z_TYPE_P(wsdl) != IS_NULL) { service->sdl = get_sdl(getThis(), Z_STRVAL_P(wsdl), cache_wsdl); @@ -1415,8 +1414,7 @@ PHP_METHOD(SoapServer, addFunction) if (service->soap_functions.ft == NULL) { service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, zend_hash_num_elements(Z_ARRVAL_P(function_name)), NULL, ZVAL_PTR_DTOR, 0); + service->soap_functions.ft = zend_new_array(zend_hash_num_elements(Z_ARRVAL_P(function_name))); } ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(function_name), tmp_function) { @@ -1455,8 +1453,7 @@ PHP_METHOD(SoapServer, addFunction) } if (service->soap_functions.ft == NULL) { service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); + service->soap_functions.ft = zend_new_array(0); } ZVAL_STR_COPY(&function_copy, f->common.function_name); @@ -2888,8 +2885,7 @@ PHP_METHOD(SoapClient, __call) free_soap_headers = 0; } else if (Z_TYPE_P(headers) == IS_OBJECT && instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) { - soap_headers = emalloc(sizeof(HashTable)); - zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0); + soap_headers = zend_new_array(0); zend_hash_next_index_insert(soap_headers, headers); Z_ADDREF_P(headers); free_soap_headers = 1; diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index a45197114a..672f40e469 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -845,8 +845,7 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */ HashTable *debug_info; *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - ZEND_INIT_SYMTABLE_EX(debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0); + debug_info = zend_new_array(zend_hash_num_elements(intern->std.properties) + 1); zend_hash_copy(debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref); storage = &intern->array; diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 667a6bad7b..af78e68f4d 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -506,8 +506,7 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp) /* { rebuild_object_properties(&intern->std); } - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 1, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(1); zend_hash_copy(debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref); pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "flags", sizeof("flags")-1); diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 06e4773677..3b179c523f 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -490,8 +490,7 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv rebuild_object_properties(&intern->std); } - ALLOC_HASHTABLE(debug_info); - ZEND_INIT_SYMTABLE_EX(debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0); + debug_info = zend_new_array(zend_hash_num_elements(intern->std.properties) + 1); zend_hash_copy(debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref); pnstr = spl_gen_private_prop_name(ce, "flags", sizeof("flags")-1); diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index de33bd5a6b..c6d366515b 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -295,8 +295,7 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{ props = Z_OBJPROP_P(obj); - ALLOC_HASHTABLE(debug_info); - ZEND_INIT_SYMTABLE_EX(debug_info, zend_hash_num_elements(props) + 1, 0); + debug_info = zend_new_array(zend_hash_num_elements(props) + 1); zend_hash_copy(debug_info, props, (copy_ctor_func_t)zval_add_ref); array_init(&storage); diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 1b264f1eb9..cc126d77be 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -276,9 +276,7 @@ static HashTable *browscap_entry_to_array(browser_data *bdata, browscap_entry *e zval tmp; uint32_t i; - HashTable *ht; - ALLOC_HASHTABLE(ht); - zend_hash_init(ht, 8, NULL, ZVAL_PTR_DTOR, 0); + HashTable *ht = zend_new_array(8); ZVAL_STR(&tmp, browscap_convert_pattern(entry->pattern, 0)); zend_hash_str_add(ht, "browser_name_regex", sizeof("browser_name_regex")-1, &tmp); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 979a64b913..afd8088caf 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -665,8 +665,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds) if (Z_TYPE_P(stream_array) != IS_ARRAY) { return 0; } - ZVAL_NEW_ARR(&new_array); - zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0); + array_init_size(&new_array, zend_hash_num_elements(Z_ARRVAL_P(stream_array))); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(stream_array), num_ind, key, elem) { php_socket_t this_fd; @@ -714,8 +713,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array) if (Z_TYPE_P(stream_array) != IS_ARRAY) { return 0; } - ZVAL_NEW_ARR(&new_array); - zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0); + array_init_size(&new_array, zend_hash_num_elements(Z_ARRVAL_P(stream_array))); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(stream_array), elem) { ZVAL_DEREF(elem); diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index b7160232ef..61afc36099 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -113,10 +113,8 @@ zend_object *xsl_objects_new(zend_class_entry *class_type) zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); - ALLOC_HASHTABLE(intern->parameter); - zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0); - ALLOC_HASHTABLE(intern->registered_phpfunctions); - zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->parameter = zend_new_array(0); + intern->registered_phpfunctions = zend_new_array(0); intern->std.handlers = &xsl_object_handlers; return &intern->std; diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 3970e267ba..02c436e340 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -343,8 +343,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t xmlNode *nodep; dom_object *obj; if (intern->node_list == NULL) { - ALLOC_HASHTABLE(intern->node_list); - zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->node_list = zend_new_array(0); } Z_ADDREF(retval); zend_hash_next_index_insert(intern->node_list, &retval); |