diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-04-21 18:25:34 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-04-21 18:25:34 +0400 |
commit | 72c287bd232ef3a0dc5ae76a4b5b5879a8ee7786 (patch) | |
tree | 8faa259c298da79116fac7e6efc370434af70f6d /Zend | |
parent | afe66d89a122d0349f56ddd4c4abfd5d2da68f19 (diff) | |
download | php-git-72c287bd232ef3a0dc5ae76a4b5b5879a8ee7786.tar.gz |
Combine HashTable.flags and HashTable.nApplyCount into single 32-bit word
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend.c | 36 | ||||
-rw-r--r-- | Zend/zend_closures.c | 4 | ||||
-rw-r--r-- | Zend/zend_compile.c | 24 | ||||
-rw-r--r-- | Zend/zend_constants.c | 4 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 6 | ||||
-rw-r--r-- | Zend/zend_hash.c | 103 | ||||
-rw-r--r-- | Zend/zend_hash.h | 24 | ||||
-rw-r--r-- | Zend/zend_ini.c | 8 | ||||
-rw-r--r-- | Zend/zend_list.c | 16 | ||||
-rw-r--r-- | Zend/zend_object_handlers.c | 4 | ||||
-rw-r--r-- | Zend/zend_objects.c | 2 | ||||
-rw-r--r-- | Zend/zend_operators.c | 6 | ||||
-rw-r--r-- | Zend/zend_string.c | 10 | ||||
-rw-r--r-- | Zend/zend_ts_hash.c | 8 | ||||
-rw-r--r-- | Zend/zend_ts_hash.h | 4 | ||||
-rw-r--r-- | Zend/zend_types.h | 11 |
16 files changed, 132 insertions, 138 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index cef24c085b..4e12a79059 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -345,14 +345,14 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */ switch (Z_TYPE_P(expr)) { case IS_ARRAY: ZEND_PUTS("Array ("); - if (++Z_ARRVAL_P(expr)->nApplyCount>1) { + if (++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) { ZEND_PUTS(" *RECURSION*"); - Z_ARRVAL_P(expr)->nApplyCount--; + Z_ARRVAL_P(expr)->u.v.nApplyCount--; return; } print_flat_hash(Z_ARRVAL_P(expr) TSRMLS_CC); ZEND_PUTS(")"); - Z_ARRVAL_P(expr)->nApplyCount--; + Z_ARRVAL_P(expr)->u.v.nApplyCount--; break; case IS_OBJECT: { @@ -374,13 +374,13 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC) /* {{{ */ properties = Z_OBJPROP_P(expr); } if (properties) { - if (++properties->nApplyCount>1) { + if (++properties->u.v.nApplyCount>1) { ZEND_PUTS(" *RECURSION*"); - properties->nApplyCount--; + properties->u.v.nApplyCount--; return; } print_flat_hash(properties TSRMLS_CC); - properties->nApplyCount--; + properties->u.v.nApplyCount--; } ZEND_PUTS(")"); break; @@ -404,13 +404,13 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int switch (Z_TYPE_P(expr)) { case IS_ARRAY: ZEND_PUTS_EX("Array\n"); - if (++Z_ARRVAL_P(expr)->nApplyCount>1) { + if (++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) { ZEND_PUTS_EX(" *RECURSION*"); - Z_ARRVAL_P(expr)->nApplyCount--; + Z_ARRVAL_P(expr)->u.v.nApplyCount--; return; } print_hash(write_func, Z_ARRVAL_P(expr), indent, 0 TSRMLS_CC); - Z_ARRVAL_P(expr)->nApplyCount--; + Z_ARRVAL_P(expr)->u.v.nApplyCount--; break; case IS_OBJECT: { @@ -433,13 +433,13 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) { break; } - if (++properties->nApplyCount>1) { + if (++properties->u.v.nApplyCount>1) { ZEND_PUTS_EX(" *RECURSION*"); - properties->nApplyCount--; + properties->u.v.nApplyCount--; return; } print_hash(write_func, properties, indent, 1 TSRMLS_CC); - properties->nApplyCount--; + properties->u.v.nApplyCount--; if (is_temp) { zend_hash_destroy(properties); efree(properties); @@ -516,11 +516,11 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals TSRMLS compiler_globals->compiled_filename = NULL; compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0); + zend_hash_init_ex(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0); zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0); + zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0); zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref); zend_set_default_compile_time_values(TSRMLS_C); @@ -723,12 +723,12 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable)); GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0); - zend_hash_init_ex(GLOBAL_CLASS_TABLE, 10, NULL, ZEND_CLASS_DTOR, 1, 0); + zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0); + zend_hash_init_ex(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1, 0); zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1, 0); - zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 20, NULL, ZEND_CONSTANT_DTOR, 1, 0); + zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1, 0); - zend_hash_init_ex(&module_registry, 50, NULL, module_destructor_zval, 1, 0); + zend_hash_init_ex(&module_registry, 32, NULL, module_destructor_zval, 1, 0); zend_init_rsrc_list_dtors(); #ifdef ZTS diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 7b587a9223..9f58ce8541 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -292,9 +292,9 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_ if (closure->debug_info == NULL) { ALLOC_HASHTABLE(closure->debug_info); - zend_hash_init(closure->debug_info, 1, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(closure->debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); } - if (closure->debug_info->nApplyCount == 0) { + if (closure->debug_info->u.v.nApplyCount == 0) { if (closure->func.type == ZEND_USER_FUNCTION && closure->func.op_array.static_variables) { HashTable *static_variables = closure->func.op_array.static_variables; array_init(&val); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 14d937bb55..1077180df1 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -213,7 +213,7 @@ void zend_init_compiler_data_structures(TSRMLS_D) /* {{{ */ CG(current_import) = NULL; CG(current_import_function) = NULL; CG(current_import_const) = NULL; - zend_hash_init(&CG(const_filenames), 0, NULL, NULL, 0); + zend_hash_init(&CG(const_filenames), 8, NULL, NULL, 0); init_compiler_declarables(TSRMLS_C); zend_stack_init(&CG(context_stack)); @@ -235,7 +235,7 @@ void init_compiler(TSRMLS_D) /* {{{ */ memset(&CG(context), 0, sizeof(CG(context))); zend_init_compiler_data_structures(TSRMLS_C); zend_init_rsrc_list(TSRMLS_C); - zend_hash_init(&CG(filenames_table), 5, NULL, free_string_zval, 0); + zend_hash_init(&CG(filenames_table), 8, NULL, free_string_zval, 0); zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) file_handle_dtor, 0); CG(unclean_shutdown) = 0; } @@ -2364,7 +2364,7 @@ void zend_do_label(znode *label TSRMLS_DC) /* {{{ */ if (!CG(context).labels) { ALLOC_HASHTABLE(CG(context).labels); - zend_hash_init(CG(context).labels, 4, NULL, ptr_dtor, 0); + zend_hash_init(CG(context).labels, 8, NULL, ptr_dtor, 0); } dest.brk_cont = CG(context).current_brk_cont; @@ -4066,7 +4066,7 @@ static void zend_add_trait_method(zend_class_entry *ce, const char *name, zend_s } } else { ALLOC_HASHTABLE(*overriden); - zend_hash_init_ex(*overriden, 2, NULL, ptr_dtor, 0, 0); + zend_hash_init_ex(*overriden, 8, NULL, ptr_dtor, 0, 0); } fn = zend_hash_update_mem(*overriden, key, fn, sizeof(zend_function)); return; @@ -4371,7 +4371,7 @@ static void zend_do_traits_method_binding(zend_class_entry *ce TSRMLS_DC) /* {{{ HashTable exclude_table; /* TODO: revisit this start size, may be its not optimal */ - zend_hash_init_ex(&exclude_table, 2, NULL, NULL, 0, 0); + zend_hash_init_ex(&exclude_table, 8, NULL, NULL, 0, 0); zend_traits_compile_exclude_table(&exclude_table, ce->trait_precedences, ce->traits[i]); @@ -6115,7 +6115,7 @@ void zend_do_fetch_static_variable(znode *varname, const znode *static_assignmen 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, 2, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(CG(active_op_array)->static_variables, 8, NULL, ZVAL_PTR_DTOR, 0); } zend_hash_update(CG(active_op_array)->static_variables, Z_STR(varname->u.constant), &tmp); @@ -6933,9 +6933,9 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify ce->default_properties_table = NULL; ce->default_static_members_table = NULL; - zend_hash_init_ex(&ce->properties_info, 0, NULL, (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, 0); - zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, 0); - zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0); + zend_hash_init_ex(&ce->properties_info, 8, NULL, (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, 0); + zend_hash_init_ex(&ce->constants_table, 8, NULL, zval_ptr_dtor_func, persistent_hashes, 0); + zend_hash_init_ex(&ce->function_table, 8, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0); if (ce->type == ZEND_INTERNAL_CLASS) { #ifdef ZTS @@ -7136,7 +7136,7 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{ if (!CG(current_import)) { CG(current_import) = emalloc(sizeof(HashTable)); - zend_hash_init(CG(current_import), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(CG(current_import), 8, NULL, ZVAL_PTR_DTOR, 0); } ZVAL_ZVAL(&ns, &ns_name->u.constant, 0, 0); @@ -7299,7 +7299,7 @@ void zend_do_use_function(znode *ns_name, znode *new_name, int is_global TSRMLS_ { if (!CG(current_import_function)) { CG(current_import_function) = emalloc(sizeof(HashTable)); - zend_hash_init(CG(current_import_function), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(CG(current_import_function), 8, NULL, ZVAL_PTR_DTOR, 0); } zend_do_use_non_class(ns_name, new_name, is_global, 1, 0, CG(current_import_function), CG(function_table) TSRMLS_CC); @@ -7310,7 +7310,7 @@ void zend_do_use_const(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) { if (!CG(current_import_const)) { CG(current_import_const) = emalloc(sizeof(HashTable)); - zend_hash_init(CG(current_import_const), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(CG(current_import_const), 8, NULL, ZVAL_PTR_DTOR, 0); } zend_do_use_non_class(ns_name, new_name, is_global, 0, 1, CG(current_import_const), &CG(const_filenames) TSRMLS_CC); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index f3c58065ee..30ae65d267 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -102,9 +102,7 @@ int zend_startup_constants(TSRMLS_D) { EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable)); - if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) { - return FAILURE; - } + zend_hash_init(EG(zend_constants), 128, NULL, ZEND_CONSTANT_DTOR, 1); return SUCCESS; } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f976a80705..44e3f08895 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -160,13 +160,13 @@ void init_executor(TSRMLS_D) /* {{{ */ ZVAL_LONG(&tmp, 0); zend_vm_stack_push(&tmp TSRMLS_CC); - zend_hash_init(&EG(symbol_table).ht, 50, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&EG(symbol_table).ht, 64, NULL, ZVAL_PTR_DTOR, 0); EG(active_symbol_table) = &EG(symbol_table); zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC); EG(opline_ptr) = NULL; - zend_hash_init(&EG(included_files), 5, NULL, NULL, 0); + zend_hash_init(&EG(included_files), 8, NULL, NULL, 0); EG(ticks_count) = 0; @@ -1082,7 +1082,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k if (EG(in_autoload) == NULL) { ALLOC_HASHTABLE(EG(in_autoload)); - zend_hash_init(EG(in_autoload), 0, NULL, NULL, 0); + zend_hash_init(EG(in_autoload), 8, NULL, NULL, 0); } if (zend_hash_add_empty_element(EG(in_autoload), lc_name) == NULL) { diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 5e3f823c83..38e027d608 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -33,10 +33,10 @@ static void _zend_is_inconsistent(const HashTable *ht, const char *file, int line) { - if ((ht->flags & HASH_MASK_CONSISTENCY) == HT_OK) { + if ((ht->u.flags & HASH_MASK_CONSISTENCY) == HT_OK) { return; } - switch ((ht->flags & HASH_MASK_CONSISTENCY)) { + switch ((ht->u.flags & HASH_MASK_CONSISTENCY)) { case HT_IS_DESTROYING: zend_output_debug_string(1, "%s(%d) : ht=%p is being destroyed", file, line, ht); break; @@ -54,7 +54,7 @@ static void _zend_is_inconsistent(const HashTable *ht, const char *file, int lin } #define IS_CONSISTENT(a) _zend_is_inconsistent(a, __FILE__, __LINE__); #define SET_INCONSISTENT(n) do { \ - (ht)->flags |= n; \ + (ht)->u.flags |= n; \ } while (0) #else #define IS_CONSISTENT(a) @@ -62,15 +62,16 @@ static void _zend_is_inconsistent(const HashTable *ht, const char *file, int lin #endif #define HASH_PROTECT_RECURSION(ht) \ - if ((ht)->flags & HASH_FLAG_APPLY_PROTECTION) { \ - if ((ht)->nApplyCount++ >= 3) { \ - zend_error(E_ERROR, "Nesting level too deep - recursive dependency?"); \ + if ((ht)->u.flags & HASH_FLAG_APPLY_PROTECTION) { \ + if ((ht)->u.flags >= (3 << 8)) { \ + zend_error_noreturn(E_ERROR, "Nesting level too deep - recursive dependency?");\ } \ + (ht)->u.flags += (1 << 8); \ } #define HASH_UNPROTECT_RECURSION(ht) \ - if ((ht)->flags & HASH_FLAG_APPLY_PROTECTION) { \ - (ht)->nApplyCount--; \ + if ((ht)->u.flags & HASH_FLAG_APPLY_PROTECTION) { \ + (ht)->u.flags -= (1 << 8); \ } #define ZEND_HASH_IF_FULL_DO_RESIZE(ht) \ @@ -83,10 +84,10 @@ static void zend_hash_do_resize(HashTable *ht); #define CHECK_INIT(ht, packed) do { \ if (UNEXPECTED((ht)->nTableMask == 0)) { \ if (packed) { \ - (ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket), 0, (ht)->flags & HASH_FLAG_PERSISTENT); \ - (ht)->flags |= HASH_FLAG_PACKED; \ + (ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket), 0, (ht)->u.flags & HASH_FLAG_PERSISTENT); \ + (ht)->u.flags |= HASH_FLAG_PACKED; \ } else { \ - (ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, (ht)->flags & HASH_FLAG_PERSISTENT); \ + (ht)->arData = (Bucket *) safe_pemalloc((ht)->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, (ht)->u.flags & HASH_FLAG_PERSISTENT); \ (ht)->arHash = (zend_uint*)((ht)->arData + (ht)->nTableSize); \ memset((ht)->arHash, INVALID_IDX, (ht)->nTableSize * sizeof(zend_uint)); \ } \ @@ -96,11 +97,10 @@ static void zend_hash_do_resize(HashTable *ht); static const zend_uint uninitialized_bucket = {INVALID_IDX}; -ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) +ZEND_API void _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { uint i = 3; - ht->flags = 0; SET_INCONSISTENT(HT_OK); if (nSize >= 0x80000000) { @@ -114,25 +114,24 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, } ht->nTableMask = 0; /* 0 means that ht->arBuckets is uninitialized */ - ht->pDestructor = pDestructor; - ht->arData = NULL; - ht->arHash = (zend_uint*)&uninitialized_bucket; ht->nNumUsed = 0; ht->nNumOfElements = 0; ht->nNextFreeElement = 0; + ht->arData = NULL; + ht->arHash = (zend_uint*)&uninitialized_bucket; + ht->pDestructor = pDestructor; ht->nInternalPointer = INVALID_IDX; - ht->flags |= HASH_FLAG_APPLY_PROTECTION; if (persistent) { - ht->flags |= HASH_FLAG_PERSISTENT; + ht->u.flags = HASH_FLAG_PERSISTENT | HASH_FLAG_APPLY_PROTECTION; + } else { + ht->u.flags = HASH_FLAG_APPLY_PROTECTION; } - ht->nApplyCount = 0; - return SUCCESS; } static void zend_hash_packed_grow(HashTable *ht) { HANDLE_BLOCK_INTERRUPTIONS(); - ht->arData = (Bucket *) safe_perealloc(ht->arData, (ht->nTableSize << 1), sizeof(Bucket), 0, ht->flags & HASH_FLAG_PERSISTENT); + ht->arData = (Bucket *) safe_perealloc(ht->arData, (ht->nTableSize << 1), sizeof(Bucket), 0, ht->u.flags & HASH_FLAG_PERSISTENT); ht->nTableSize = (ht->nTableSize << 1); ht->nTableMask = ht->nTableSize - 1; HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -148,8 +147,8 @@ ZEND_API void zend_hash_real_init(HashTable *ht, int packed) ZEND_API void zend_hash_packed_to_hash(HashTable *ht) { HANDLE_BLOCK_INTERRUPTIONS(); - ht->flags &= ~HASH_FLAG_PACKED; - ht->arData = (Bucket *) safe_perealloc(ht->arData, ht->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, ht->flags & HASH_FLAG_PERSISTENT); + ht->u.flags &= ~HASH_FLAG_PACKED; + ht->arData = (Bucket *) safe_perealloc(ht->arData, ht->nTableSize, sizeof(Bucket) + sizeof(zend_uint), 0, ht->u.flags & HASH_FLAG_PERSISTENT); ht->arHash = (zend_uint*)(ht->arData + ht->nTableSize); zend_hash_rehash(ht); HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -158,29 +157,27 @@ ZEND_API void zend_hash_packed_to_hash(HashTable *ht) ZEND_API void zend_hash_to_packed(HashTable *ht) { HANDLE_BLOCK_INTERRUPTIONS(); - ht->flags |= HASH_FLAG_PACKED; + ht->u.flags |= HASH_FLAG_PACKED; ht->arData = erealloc(ht->arData, ht->nTableSize * sizeof(Bucket)); ht->arHash = (zend_uint*)&uninitialized_bucket; HANDLE_UNBLOCK_INTERRUPTIONS(); } -ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) +ZEND_API void _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) { - int retval = _zend_hash_init(ht, nSize, pDestructor, persistent ZEND_FILE_LINE_CC); - + _zend_hash_init(ht, nSize, pDestructor, persistent ZEND_FILE_LINE_CC); if (!bApplyProtection) { - ht->flags &= ~HASH_FLAG_APPLY_PROTECTION; + ht->u.flags &= ~HASH_FLAG_APPLY_PROTECTION; } - return retval; } ZEND_API void zend_hash_set_apply_protection(HashTable *ht, zend_bool bApplyProtection) { if (bApplyProtection) { - ht->flags |= HASH_FLAG_APPLY_PROTECTION; + ht->u.flags |= HASH_FLAG_APPLY_PROTECTION; } else { - ht->flags &= ~HASH_FLAG_APPLY_PROTECTION; + ht->u.flags &= ~HASH_FLAG_APPLY_PROTECTION; } } @@ -260,7 +257,7 @@ ZEND_API zval *_zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *p IS_CONSISTENT(ht); CHECK_INIT(ht, 0); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { zend_hash_packed_to_hash(ht); } @@ -310,7 +307,7 @@ ZEND_API zval *_zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *p ZEND_API zval *_zend_hash_str_add_or_update(HashTable *ht, const char *str, int len, zval *pData, int flag ZEND_FILE_LINE_DC) { - zend_string *key = STR_INIT(str, len, ht->flags & HASH_FLAG_PERSISTENT); + zend_string *key = STR_INIT(str, len, ht->u.flags & HASH_FLAG_PERSISTENT); zval *ret = _zend_hash_add_or_update(ht, key, pData, flag ZEND_FILE_LINE_CC); STR_RELEASE(key); return ret; @@ -350,7 +347,7 @@ ZEND_API zval *_zend_hash_index_update_or_next_insert(HashTable *ht, ulong h, zv } CHECK_INIT(ht, h >= 0 && h < ht->nTableSize); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { if (EXPECTED(h >= 0)) { if (h < ht->nNumUsed) { p = ht->arData + h; @@ -465,7 +462,7 @@ static void zend_hash_do_resize(HashTable *ht) HANDLE_UNBLOCK_INTERRUPTIONS(); } else if ((ht->nTableSize << 1) > 0) { /* Let's double the table size */ HANDLE_BLOCK_INTERRUPTIONS(); - ht->arData = (Bucket *) safe_perealloc(ht->arData, (ht->nTableSize << 1), sizeof(Bucket) + sizeof(zend_uint), 0, ht->flags & HASH_FLAG_PERSISTENT); + ht->arData = (Bucket *) safe_perealloc(ht->arData, (ht->nTableSize << 1), sizeof(Bucket) + sizeof(zend_uint), 0, ht->u.flags & HASH_FLAG_PERSISTENT); ht->arHash = (zend_uint*)(ht->arData + (ht->nTableSize << 1)); ht->nTableSize = (ht->nTableSize << 1); ht->nTableMask = ht->nTableSize - 1; @@ -506,7 +503,7 @@ ZEND_API int zend_hash_rehash(HashTable *ht) static zend_always_inline void _zend_hash_del_el_ex(HashTable *ht, uint idx, Bucket *p, Bucket *prev) { - if (!(ht->flags & HASH_FLAG_PACKED)) { + if (!(ht->u.flags & HASH_FLAG_PACKED)) { if (prev) { Z_NEXT(prev->val) = Z_NEXT(p->val); } else { @@ -549,7 +546,7 @@ static zend_always_inline void _zend_hash_del_el(HashTable *ht, uint idx, Bucket uint nIndex; Bucket *prev = NULL; - if (!(ht->flags & HASH_FLAG_PACKED)) { + if (!(ht->u.flags & HASH_FLAG_PACKED)) { nIndex = p->h & ht->nTableMask; idx = ht->arHash[nIndex]; if (p != ht->arData + idx) { @@ -578,7 +575,7 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { return FAILURE; } @@ -617,7 +614,7 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { return FAILURE; } @@ -749,7 +746,7 @@ ZEND_API int zend_hash_index_del(HashTable *ht, ulong h) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { if (h >=0 && h < ht->nNumUsed) { p = ht->arData + h; if (Z_TYPE(p->val) != IS_UNDEF) { @@ -798,7 +795,7 @@ ZEND_API void zend_hash_destroy(HashTable *ht) } } if (ht->nTableMask) { - pefree(ht->arData, ht->flags & HASH_FLAG_PERSISTENT); + pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT); } SET_INCONSISTENT(HT_DESTROYED); @@ -827,7 +824,7 @@ ZEND_API void zend_hash_clean(HashTable *ht) ht->nNextFreeElement = 0; ht->nInternalPointer = INVALID_IDX; if (ht->nTableMask) { - if (!(ht->flags & HASH_FLAG_PACKED)) { + if (!(ht->u.flags & HASH_FLAG_PACKED)) { memset(ht->arHash, INVALID_IDX, ht->nTableSize * sizeof(zend_uint)); } } @@ -863,7 +860,7 @@ ZEND_API void zend_hash_graceful_destroy(HashTable *ht) zend_hash_apply_deleter(ht, idx, p); } if (ht->nTableMask) { - pefree(ht->arData, ht->flags & HASH_FLAG_PERSISTENT); + pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT); } SET_INCONSISTENT(HT_DESTROYED); @@ -885,7 +882,7 @@ ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht) } if (ht->nTableMask) { - pefree(ht->arData, ht->flags & HASH_FLAG_PERSISTENT); + pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT); } SET_INCONSISTENT(HT_DESTROYED); @@ -1146,7 +1143,7 @@ ZEND_API zval *zend_hash_find(const HashTable *ht, zend_string *key) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { return NULL; } @@ -1161,7 +1158,7 @@ ZEND_API zval *zend_hash_str_find(const HashTable *ht, const char *str, int len) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { return NULL; } @@ -1176,7 +1173,7 @@ ZEND_API int zend_hash_exists(const HashTable *ht, zend_string *key) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { return 0; } @@ -1191,7 +1188,7 @@ ZEND_API int zend_hash_str_exists(const HashTable *ht, const char *str, int len) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { return 0; } @@ -1206,7 +1203,7 @@ ZEND_API zval *zend_hash_index_find(const HashTable *ht, ulong h) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { if (h >= 0 && h < ht->nNumUsed) { p = ht->arData + h; if (Z_TYPE(p->val) != IS_UNDEF) { @@ -1227,7 +1224,7 @@ ZEND_API int zend_hash_index_exists(const HashTable *ht, ulong h) IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { if (h >= 0 && h < ht->nNumUsed) { if (Z_TYPE(ht->arData[h].val) != IS_UNDEF) { return 1; @@ -1280,7 +1277,7 @@ ZEND_API int zend_hash_set_pointer(HashTable *ht, const HashPointer *ptr) return 0; } else if (ht->nInternalPointer != ptr->pos) { IS_CONSISTENT(ht); - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { if (Z_TYPE(ht->arData[ptr->h].val) != IS_UNDEF) { ht->nInternalPointer = ptr->h; return 1; @@ -1606,13 +1603,13 @@ ZEND_API int zend_hash_sort(HashTable *ht, sort_func_t sort_func, if (renumber) { ht->nNextFreeElement = i; } - if (ht->flags & HASH_FLAG_PACKED) { + if (ht->u.flags & HASH_FLAG_PACKED) { if (!renumber) { zend_hash_packed_to_hash(ht); } } else { if (renumber) { - ht->flags |= HASH_FLAG_PACKED; + ht->u.flags |= HASH_FLAG_PACKED; ht->arData = erealloc(ht->arData, ht->nTableSize * sizeof(Bucket)); ht->arHash = (zend_uint*)&uninitialized_bucket; } else { diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 6a15b437a5..cc1dcca0e7 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -60,8 +60,8 @@ typedef uint HashPosition; BEGIN_EXTERN_C() /* startup/shutdown */ -ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC); -ZEND_API int _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC); +ZEND_API void _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC); +ZEND_API void _zend_hash_init_ex(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC); ZEND_API void zend_hash_destroy(HashTable *ht); ZEND_API void 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) @@ -207,7 +207,7 @@ void zend_hash_display(const HashTable *ht); END_EXTERN_C() #define ZEND_INIT_SYMTABLE(ht) \ - ZEND_INIT_SYMTABLE_EX(ht, 2, 0) + ZEND_INIT_SYMTABLE_EX(ht, 8, 0) #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \ zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) @@ -418,12 +418,12 @@ static inline void *zend_hash_add_mem(HashTable *ht, zend_string *key, void *pDa { void *p, *r; - p = pemalloc(size, ht->flags & HASH_FLAG_PERSISTENT); + p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); memcpy(p, pData, size); if ((r = zend_hash_add_ptr(ht, key, p))) { return r; } - pefree(p, ht->flags & HASH_FLAG_PERSISTENT); + pefree(p, ht->u.flags & HASH_FLAG_PERSISTENT); return NULL; } @@ -431,12 +431,12 @@ static inline void *zend_hash_str_add_mem(HashTable *ht, const char *str, int le { void *p, *r; - p = pemalloc(size, ht->flags & HASH_FLAG_PERSISTENT); + p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); memcpy(p, pData, size); if ((r = zend_hash_str_add_ptr(ht, str, len, p))) { return r; } - pefree(p, ht->flags & HASH_FLAG_PERSISTENT); + pefree(p, ht->u.flags & HASH_FLAG_PERSISTENT); return NULL; } @@ -444,7 +444,7 @@ static inline void *zend_hash_update_mem(HashTable *ht, zend_string *key, void * { void *p; - p = pemalloc(size, ht->flags & HASH_FLAG_PERSISTENT); + p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); memcpy(p, pData, size); return zend_hash_update_ptr(ht, key, p); } @@ -453,7 +453,7 @@ static inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, int { void *p; - p = pemalloc(size, ht->flags & HASH_FLAG_PERSISTENT); + p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); memcpy(p, pData, size); return zend_hash_str_update_ptr(ht, str, len, p); } @@ -480,7 +480,7 @@ static inline void *zend_hash_index_update_mem(HashTable *ht, ulong h, void *pDa { void *p; - p = pemalloc(size, ht->flags & HASH_FLAG_PERSISTENT); + p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); memcpy(p, pData, size); return zend_hash_index_update_ptr(ht, h, p); } @@ -489,12 +489,12 @@ static inline void *zend_hash_next_index_insert_mem(HashTable *ht, void *pData, { void *p, *r; - p = pemalloc(size, ht->flags & HASH_FLAG_PERSISTENT); + p = pemalloc(size, ht->u.flags & HASH_FLAG_PERSISTENT); memcpy(p, pData, size); if ((r = zend_hash_next_index_insert_ptr(ht, p))) { return r; } - pefree(p, ht->flags & HASH_FLAG_PERSISTENT); + pefree(p, ht->u.flags & HASH_FLAG_PERSISTENT); return NULL; } diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 4ac379ca91..883a6bf84b 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -99,9 +99,7 @@ ZEND_API int zend_ini_startup(TSRMLS_D) /* {{{ */ EG(ini_directives) = registered_zend_ini_directives; EG(modified_ini_directives) = NULL; EG(error_reporting_ini_entry) = NULL; - if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, _free_ptr, 1, 0) == FAILURE) { - return FAILURE; - } + zend_hash_init_ex(registered_zend_ini_directives, 128, NULL, _free_ptr, 1, 0); return SUCCESS; } /* }}} */ @@ -140,9 +138,7 @@ ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */ EG(modified_ini_directives) = NULL; EG(error_reporting_ini_entry) = NULL; EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable)); - if (zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0) == FAILURE) { - return FAILURE; - } + zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0); zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, NULL); return SUCCESS; } diff --git a/Zend/zend_list.c b/Zend/zend_list.c index acd756bc99..fa1af76397 100644 --- a/Zend/zend_list.c +++ b/Zend/zend_list.c @@ -203,18 +203,15 @@ void plist_entry_destructor(zval *zv) int zend_init_rsrc_list(TSRMLS_D) { - if (zend_hash_init(&EG(regular_list), 0, NULL, list_entry_destructor, 0)==SUCCESS) { - EG(regular_list).nNextFreeElement = 1; /* we don't want resource id 0 */ - return SUCCESS; - } else { - return FAILURE; - } + zend_hash_init(&EG(regular_list), 8, NULL, list_entry_destructor, 0); + return SUCCESS; } int zend_init_rsrc_plist(TSRMLS_D) { - return zend_hash_init_ex(&EG(persistent_list), 0, NULL, plist_entry_destructor, 1, 0); + zend_hash_init_ex(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1, 0); + return SUCCESS; } @@ -334,10 +331,9 @@ int zend_init_rsrc_list_dtors(void) { int retval; - retval = zend_hash_init(&list_destructors, 50, NULL, list_destructors_dtor, 1); + zend_hash_init(&list_destructors, 64, NULL, list_destructors_dtor, 1); list_destructors.nNextFreeElement=1; /* we don't want resource type 0 */ - - return retval; + return SUCCESS; } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index edf7c2ccd3..7a14ce939a 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -75,7 +75,7 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ zend_class_entry *ce = zobj->ce; ALLOC_HASHTABLE(zobj->properties); - zend_hash_init(zobj->properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(zobj->properties, 8, NULL, ZVAL_PTR_DTOR, 0); if (ce->default_properties_count) { ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) { if (/*prop_info->ce == ce &&*/ @@ -399,7 +399,7 @@ static long *zend_get_property_guard(zend_object *zobj, zend_property_info *prop } if (!zobj->guards) { ALLOC_HASHTABLE(zobj->guards); - zend_hash_init(zobj->guards, 0, NULL, NULL, 0); + zend_hash_init(zobj->guards, 8, NULL, NULL, 0); } else if ((guard = zend_hash_find(zobj->guards, property_info->name)) != NULL) { if (str) { STR_RELEASE(str); diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 2ffec7cd8e..1ef0e1d7e7 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -154,7 +154,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o if (!new_object->properties) { ALLOC_HASHTABLE(new_object->properties); - zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(new_object->properties, 8, NULL, ZVAL_PTR_DTOR, 0); } ZEND_HASH_FOREACH_KEY_VAL(old_object->properties, num_key, key, prop) { diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 47e2562da8..0d45adf3af 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -683,7 +683,7 @@ static void convert_scalar_to_array(zval *op, int type TSRMLS_DC) /* {{{ */ switch (type) { case IS_ARRAY: ZVAL_NEW_ARR(op); - zend_hash_init(Z_ARRVAL_P(op), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(Z_ARRVAL_P(op), 8, NULL, ZVAL_PTR_DTOR, 0); zend_hash_index_update(Z_ARRVAL_P(op), 0, &entry); break; case IS_OBJECT: @@ -707,7 +707,7 @@ ZEND_API void convert_to_array(zval *op) /* {{{ */ zval arr; ZVAL_NEW_ARR(&arr); - zend_hash_init(Z_ARRVAL(arr), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(Z_ARRVAL(arr), 8, NULL, ZVAL_PTR_DTOR, 0); if (Z_OBJCE_P(op) == zend_ce_closure) { convert_scalar_to_array(op, IS_ARRAY TSRMLS_CC); if (Z_TYPE_P(op) == IS_ARRAY) { @@ -733,7 +733,7 @@ ZEND_API void convert_to_array(zval *op) /* {{{ */ break; case IS_NULL: ZVAL_NEW_ARR(op); - zend_hash_init(Z_ARRVAL_P(op), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(Z_ARRVAL_P(op), 8, NULL, ZVAL_PTR_DTOR, 0); break; default: convert_scalar_to_array(op, IS_ARRAY TSRMLS_CC); diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 730312009d..80571ec390 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -46,11 +46,11 @@ void zend_interned_strings_init(TSRMLS_D) zend_string *str; #ifndef ZTS - zend_hash_init(&CG(interned_strings), 0, NULL, _str_dtor, 1); + zend_hash_init(&CG(interned_strings), 1024, NULL, _str_dtor, 1); CG(interned_strings).nTableMask = CG(interned_strings).nTableSize - 1; - CG(interned_strings).arData = (Bucket*) pecalloc(CG(interned_strings).nTableSize, sizeof(Bucket), CG(interned_strings).flags & HASH_FLAG_PERSISTENT); - CG(interned_strings).arHash = (zend_uint*) pecalloc(CG(interned_strings).nTableSize, sizeof(zend_uint), CG(interned_strings).flags & HASH_FLAG_PERSISTENT); + CG(interned_strings).arData = (Bucket*) pecalloc(CG(interned_strings).nTableSize, sizeof(Bucket), 1); + CG(interned_strings).arHash = (zend_uint*) pecalloc(CG(interned_strings).nTableSize, sizeof(zend_uint), 1); memset(CG(interned_strings).arHash, INVALID_IDX, CG(interned_strings).nTableSize * sizeof(zend_uint)); /* interned empty string */ @@ -112,8 +112,8 @@ static zend_string *zend_new_interned_string_int(zend_string *str TSRMLS_DC) if (CG(interned_strings).nNumUsed >= CG(interned_strings).nTableSize) { if ((CG(interned_strings).nTableSize << 1) > 0) { /* Let's double the table size */ - Bucket *d = (Bucket *) perealloc_recoverable(CG(interned_strings).arData, (CG(interned_strings).nTableSize << 1) * sizeof(Bucket), CG(interned_strings).flags & HASH_FLAG_PERSISTENT); - zend_uint *h = (zend_uint *) perealloc_recoverable(CG(interned_strings).arHash, (CG(interned_strings).nTableSize << 1) * sizeof(zend_uint), CG(interned_strings).flags & HASH_FLAG_PERSISTENT); + Bucket *d = (Bucket *) perealloc_recoverable(CG(interned_strings).arData, (CG(interned_strings).nTableSize << 1) * sizeof(Bucket), 1); + zend_uint *h = (zend_uint *) perealloc_recoverable(CG(interned_strings).arHash, (CG(interned_strings).nTableSize << 1) * sizeof(zend_uint), 1); if (d && h) { HANDLE_BLOCK_INTERRUPTIONS(); diff --git a/Zend/zend_ts_hash.c b/Zend/zend_ts_hash.c index 776f728718..92cd62128e 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 int _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) +ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif - return _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); + _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); } -ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint 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, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif - return _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_FILE_LINE_RELAY_CC); } ZEND_API void zend_ts_hash_destroy(TsHashTable *ht) diff --git a/Zend/zend_ts_hash.h b/Zend/zend_ts_hash.h index 7394efd576..4b0a507368 100644 --- a/Zend/zend_ts_hash.h +++ b/Zend/zend_ts_hash.h @@ -37,8 +37,8 @@ BEGIN_EXTERN_C() #define TS_HASH(table) (&(table->hash)) /* startup/shutdown */ -ZEND_API int _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC); -ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC); +ZEND_API void _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC); +ZEND_API void _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC); ZEND_API void zend_ts_hash_destroy(TsHashTable *ht); ZEND_API void zend_ts_hash_clean(TsHashTable *ht); diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 0142e53c40..2afd54f0ec 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -158,8 +158,15 @@ typedef struct _HashTable { zend_uint *arHash; dtor_func_t pDestructor; zend_uint nInternalPointer; - zend_uchar flags; - zend_uchar nApplyCount; + union { + struct { + ZEND_ENDIAN_LOHI_3( + zend_uchar flags, + zend_uchar nApplyCount, + zend_ushort reserve) + } v; + zend_uint flags; + } u; } HashTable; struct _zend_array { |