]> granicus.if.org Git - php/commitdiff
Combine HashTable.flags and HashTable.nApplyCount into single 32-bit word
authorDmitry Stogov <dmitry@zend.com>
Mon, 21 Apr 2014 14:25:34 +0000 (18:25 +0400)
committerDmitry Stogov <dmitry@zend.com>
Mon, 21 Apr 2014 14:25:34 +0000 (18:25 +0400)
39 files changed:
Zend/zend.c
Zend/zend_closures.c
Zend/zend_compile.c
Zend/zend_constants.c
Zend/zend_execute_API.c
Zend/zend_hash.c
Zend/zend_hash.h
Zend/zend_ini.c
Zend/zend_list.c
Zend/zend_object_handlers.c
Zend/zend_objects.c
Zend/zend_operators.c
Zend/zend_string.c
Zend/zend_ts_hash.c
Zend/zend_ts_hash.h
Zend/zend_types.h
ext/opcache/ZendAccelerator.c
ext/opcache/zend_accelerator_util_funcs.c
ext/opcache/zend_persist.c
ext/opcache/zend_persist_calc.c
ext/opcache/zend_shared_alloc.c
ext/spl/spl_array.c
ext/spl/spl_dllist.c
ext/spl/spl_heap.c
ext/spl/spl_observer.c
ext/standard/array.c
ext/standard/basic_functions.c
ext/standard/browscap.c
ext/standard/http.c
ext/standard/php_var.h
ext/standard/user_filters.c
ext/standard/var.c
main/SAPI.c
main/output.c
main/php_ini.c
main/rfc1867.c
main/streams/streams.c
sapi/cgi/cgi_main.c
sapi/cgi/fastcgi.c

index cef24c085baf07e92220977ddf805b0160e635a9..4e12a79059a2de67b16b69278ec95cbeb8c96404 100644 (file)
@@ -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
index 7b587a9223c9265dd9c1010714a31d89840dfef9..9f58ce85414e26d3ede29fb4c3f7e5e90797857d 100644 (file)
@@ -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);
index 14d937bb558d6e92d9e2a2f1a1e596929f525605..1077180df1471ec8fea41057682239561a223af4 100644 (file)
@@ -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);
index f3c58065ee0d4121864b4b6292d5614df6d2fa69..30ae65d267c080eb756577cc5e7bc042094487db 100644 (file)
@@ -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;
 }
 
index f976a80705d7c740bb37881fddb13b333524efe9..44e3f088959f09905285f3873aaaf20cbf879fc1 100644 (file)
@@ -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) {
index 5e3f823c8359e922da2726d61b9358cfff5c0b3d..38e027d6080ec4f640138b4be5dfab1ce0f3fb69 100644 (file)
 
 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 {
index 6a15b437a5c267e49d3496afafd9f7e8a74840c9..cc1dcca0e7d34517d676130d153400b806b0800f 100644 (file)
@@ -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;
 }
 
index 4ac379ca91781a130dd89f7d03fcf3b3289ef659..883a6bf84b5b156288179f5e4795613dcba04064 100644 (file)
@@ -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;
 }
index acd756bc995698307eba89425b2515964fb0d3ef..fa1af763971c0b4edfde239776082c7d59816682 100644 (file)
@@ -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;
 }
 
 
index edf7c2ccd3aacf7e2167fbbfad4d87660ec6e3d0..7a14ce939acdb11863be78a90c994a397372020e 100644 (file)
@@ -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);
index 2ffec7cd8e627edca6427385ebb5835e57394b3a..1ef0e1d7e78b3a411337e8af69e6e5045d63fd14 100644 (file)
@@ -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) {
index 47e2562da82e77184bf9d89ece57b6079a3bbbd9..0d45adf3aff36b588c5b2d6230ed55c515fcfac1 100644 (file)
@@ -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);
index 730312009d505d169197d794489fdd3f6d4fa0de..80571ec3908a7cffb2e2b8a4f611b8588290fc08 100644 (file)
@@ -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();
index 776f7287180e2223db4c0a446053dc4c1bdce2ce..92cd62128e2842694aace51ad758036d746eef8a 100644 (file)
@@ -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)
index 7394efd576b9ab4fb745ee3c2809bbb5186cf379..4b0a507368cdb6a8fc35e3f885be91b4d906880e 100644 (file)
@@ -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);
 
index 0142e53c4044f9d7536ba5aa13e503672112ae81..2afd54f0ec02fa401b5742c9944b0cbd08ff58f7 100644 (file)
@@ -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 {
index 4dec15c01b84e82c09f443c383c0f13d5187e4e4..84c397d7ab5ca4969214790c5ffac27b2a2cb4b9 100644 (file)
@@ -2351,7 +2351,7 @@ static void zend_accel_fast_shutdown(TSRMLS_D)
                        } zend_end_try();
                        EG(symbol_table).ht.pDestructor = old_destructor;
                }
-               zend_hash_init(&EG(symbol_table).ht, 0, NULL, NULL, 0);
+               zend_hash_init(&EG(symbol_table).ht, 8, NULL, NULL, 0);
                old_destructor = EG(function_table)->pDestructor;
                EG(function_table)->pDestructor = NULL;
                zend_hash_reverse_apply(EG(function_table), (apply_func_t) accel_clean_non_persistent_function TSRMLS_CC);
index 51051dd6ceff366cbb955dd8b82eb76b5037de08..c93bec7994170db663b4c947419722c560186958 100644 (file)
@@ -77,12 +77,12 @@ zend_persistent_script* create_persistent_script(void)
        zend_persistent_script *persistent_script = (zend_persistent_script *) emalloc(sizeof(zend_persistent_script));
        memset(persistent_script, 0, sizeof(zend_persistent_script));
 
-       zend_hash_init(&persistent_script->function_table, 100, NULL, (dtor_func_t) zend_accel_destroy_zend_function, 0);
+       zend_hash_init(&persistent_script->function_table, 128, NULL, (dtor_func_t) zend_accel_destroy_zend_function, 0);
        /* class_table is usually destroyed by free_persistent_script() that
         * overrides destructor. ZEND_CLASS_DTOR may be used by standard
         * PHP compiler
         */
-       zend_hash_init(&persistent_script->class_table, 10, NULL, ZEND_CLASS_DTOR, 0);
+       zend_hash_init(&persistent_script->class_table, 16, NULL, ZEND_CLASS_DTOR, 0);
 
        return persistent_script;
 }
@@ -95,7 +95,7 @@ static int compact_hash_table(HashTable *ht)
        Bucket *d;
        Bucket *p;
 
-       if (!ht->nNumOfElements || (ht->flags & HASH_FLAG_PACKED)) {
+       if (!ht->nNumOfElements || (ht->u.flags & HASH_FLAG_PACKED)) {
                /* Empty tables don't allocate space for Buckets */
                return 1;
        }
@@ -115,7 +115,7 @@ static int compact_hash_table(HashTable *ht)
                return 1;
        }
 
-       d = (Bucket *)pemalloc(nSize * (sizeof(Bucket) + sizeof(zend_uint)), ht->flags & HASH_FLAG_PERSISTENT);
+       d = (Bucket *)pemalloc(nSize * (sizeof(Bucket) + sizeof(zend_uint)), ht->u.flags & HASH_FLAG_PERSISTENT);
        if (!d) {
                return 0;
        }
@@ -128,7 +128,7 @@ static int compact_hash_table(HashTable *ht)
        }
        ht->nNumUsed = j;
 
-       pefree(ht->arData, ht->flags & HASH_FLAG_PERSISTENT);
+       pefree(ht->arData, ht->u.flags & HASH_FLAG_PERSISTENT);
 
        ht->arData = d;
        ht->arHash = (zend_uint *)(d + nSize);
@@ -360,11 +360,10 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
        ht->nNumOfElements = source->nNumOfElements;
        ht->nNextFreeElement = source->nNextFreeElement;
        ht->pDestructor = ZVAL_PTR_DTOR;
-       ht->flags = HASH_FLAG_APPLY_PROTECTION;
+       ht->u.flags = HASH_FLAG_APPLY_PROTECTION;
        ht->arData = NULL;
        ht->arHash = NULL;
        ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
-       ht->nApplyCount = 0;
 
 #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
        if (!ht->nTableMask) {
@@ -373,8 +372,8 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
        }
 #endif
 
-       if (source->flags & HASH_FLAG_PACKED) {
-               ht->flags |= HASH_FLAG_PACKED;
+       if (source->u.flags & HASH_FLAG_PACKED) {
+               ht->u.flags |= HASH_FLAG_PACKED;
                ht->arData = (Bucket *) emalloc(ht->nTableSize * sizeof(Bucket));
                ht->arHash = (zend_uint*)&uninitialized_bucket;
        } else {
@@ -389,7 +388,7 @@ static void zend_hash_clone_zval(HashTable *ht, HashTable *source, int bind)
                nIndex = p->h & ht->nTableMask;
 
                /* Insert into hash collision list */
-               if (source->flags & HASH_FLAG_PACKED) {
+               if (source->u.flags & HASH_FLAG_PACKED) {
                        Bucket *r = ht->arData + ht->nNumUsed;
                        q = ht->arData + p->h;
                        while (r != q) {
@@ -432,9 +431,8 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
        ht->nNumOfElements = source->nNumOfElements;
        ht->nNextFreeElement = source->nNextFreeElement;
        ht->pDestructor = ZEND_FUNCTION_DTOR;
-       ht->flags = HASH_FLAG_APPLY_PROTECTION;
+       ht->u.flags = HASH_FLAG_APPLY_PROTECTION;
        ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
-       ht->nApplyCount = 0;
 
 #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
        if (!ht->nTableMask) {
@@ -443,8 +441,8 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
        }
 #endif
 
-       if (source->flags & HASH_FLAG_PACKED) {
-               ht->flags |= HASH_FLAG_PACKED;
+       if (source->u.flags & HASH_FLAG_PACKED) {
+               ht->u.flags |= HASH_FLAG_PACKED;
                ht->arData = (Bucket *) emalloc(ht->nTableSize * sizeof(Bucket));
                ht->arHash = (zend_uint*)&uninitialized_bucket;
        } else {
@@ -460,7 +458,7 @@ static void zend_hash_clone_methods(HashTable *ht, HashTable *source, zend_class
                nIndex = p->h & ht->nTableMask;
 
                /* Insert into hash collision list */
-               if (source->flags & HASH_FLAG_PACKED) {
+               if (source->u.flags & HASH_FLAG_PACKED) {
                        Bucket *r = ht->arData + ht->nNumUsed;
                        q = ht->arData + p->h;
                        while (r != q) {
@@ -530,9 +528,8 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
        ht->nNumOfElements = source->nNumOfElements;
        ht->nNextFreeElement = source->nNextFreeElement;
        ht->pDestructor = zend_destroy_property_info;
-       ht->flags = HASH_FLAG_APPLY_PROTECTION;
+       ht->u.flags = HASH_FLAG_APPLY_PROTECTION;
        ht->nInternalPointer = source->nNumOfElements ? 0 : INVALID_IDX;
-       ht->nApplyCount = 0;
 
 #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
        if (!ht->nTableMask) {
@@ -541,9 +538,9 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
        }
 #endif
 
-       if (source->flags & HASH_FLAG_PACKED) {
+       if (source->u.flags & HASH_FLAG_PACKED) {
                ht->arData = (Bucket *) emalloc(ht->nTableSize * sizeof(Bucket));
-               ht->flags |= HASH_FLAG_PACKED;
+               ht->u.flags |= HASH_FLAG_PACKED;
                ht->arHash = (zend_uint*)&uninitialized_bucket;
        } else {
                ht->arData = (Bucket *) emalloc(ht->nTableSize * (sizeof(Bucket) + sizeof(zend_uint)));
@@ -558,7 +555,7 @@ static void zend_hash_clone_prop_info(HashTable *ht, HashTable *source, zend_cla
                nIndex = p->h & ht->nTableMask;
 
                /* Insert into hash collision list */
-               if (source->flags & HASH_FLAG_PACKED) {
+               if (source->u.flags & HASH_FLAG_PACKED) {
                        Bucket *r = ht->arData + ht->nNumUsed;
                        q = ht->arData + p->h;
                        while (r != q) {
index ca8835c2edf047896ee027ab1af608a56b4536f3..ca2ad5150c2582f1ffcdc70d47ea6b0f32c433da 100644 (file)
@@ -79,7 +79,7 @@ static void zend_hash_persist(HashTable *ht, zend_persist_func_t pPersistElement
                ht->arHash = (zend_uint*)&uninitialized_bucket;
                return;
        }
-       if (ht->flags & HASH_FLAG_PACKED) {
+       if (ht->u.flags & HASH_FLAG_PACKED) {
                zend_accel_store(ht->arData, sizeof(Bucket) * ht->nTableSize);
                ht->arHash = (zend_uint*)&uninitialized_bucket;
        } else {
index 20e6b083c486612be61c757c1ac708beb50b28fa..6298fb1aa20d285f7279627ae78f5274e0283ac2 100644 (file)
@@ -62,7 +62,7 @@ static uint zend_hash_persist_calc(HashTable *ht, uint (*pPersistElement)(zval *
        if (!ht->nTableMask) {
                RETURN_SIZE();
        }
-       if (ht->flags & HASH_FLAG_PACKED) {
+       if (ht->u.flags & HASH_FLAG_PACKED) {
                ADD_DUP_SIZE(ht->arData, sizeof(Bucket) * ht->nTableSize);
        } else {
                ADD_DUP_SIZE(ht->arData, (sizeof(Bucket) + sizeof(zend_uint)) * ht->nTableSize);
index 4a31d3de6a4a770ae91f049817c7dcd406e78a24..0faabee8b276c89efc4eaa21fe3c043b9cdecd8c 100644 (file)
@@ -402,7 +402,7 @@ void zend_shared_alloc_lock(TSRMLS_D)
         * won't be taken from space which is freed by efree in memdup.
         * Otherwise it leads to false matches in memdup check.
         */
-       zend_hash_init(&xlat_table, 100, NULL, NULL, 1);
+       zend_hash_init(&xlat_table, 128, NULL, NULL, 1);
 }
 
 void zend_shared_alloc_unlock(TSRMLS_D)
index 208f9de7a63e7afc6f6007c9d5f43c8d2a10cdf4..eafc280f0e10b5326c5f91e64ef4a247b5e70a7d 100644 (file)
@@ -129,7 +129,7 @@ SPL_API int spl_hash_verify_pos_ex(spl_array_object * intern, HashTable * ht TSR
 /*     IS_CONSISTENT(ht);*/
 
 /*     HASH_PROTECT_RECURSION(ht);*/
-       if (ht->flags & HASH_FLAG_PACKED) {
+       if (ht->u.flags & HASH_FLAG_PACKED) {
                if (intern->pos_h == intern->pos && Z_TYPE(ht->arData[intern->pos_h].val) != IS_UNDEF) {
                        return SUCCESS;
                }
@@ -309,7 +309,7 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, zval *object, zval
                return &EG(uninitialized_zval);
        }
 
-       if ((type == BP_VAR_W || type == BP_VAR_RW) && (ht->nApplyCount > 0)) {
+       if ((type == BP_VAR_W || type == BP_VAR_RW) && (ht->u.v.nApplyCount > 0)) {
                zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                return &EG(error_zval);;
        }
@@ -464,7 +464,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
 
        if (!offset) {
                ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-               if (ht->nApplyCount > 0) {
+               if (ht->u.v.nApplyCount > 0) {
                        zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                        return;
                }
@@ -481,7 +481,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
        switch (Z_TYPE_P(offset)) {
                case IS_STRING:
                        ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-                       if (ht->nApplyCount > 0) {
+                       if (ht->u.v.nApplyCount > 0) {
                                zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                                return;
                        }
@@ -492,7 +492,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
                case IS_BOOL:
                case IS_LONG:
                        ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-                       if (ht->nApplyCount > 0) {
+                       if (ht->u.v.nApplyCount > 0) {
                                zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                                return;
                        }
@@ -505,7 +505,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
                        return;
                case IS_NULL:
                        ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-                       if (ht->nApplyCount > 0) {
+                       if (ht->u.v.nApplyCount > 0) {
                                zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                                return;
                        }
@@ -538,7 +538,7 @@ static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval
        switch(Z_TYPE_P(offset)) {
        case IS_STRING:
                ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-               if (ht->nApplyCount > 0) {
+               if (ht->u.v.nApplyCount > 0) {
                        zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                        return;
                }
@@ -583,7 +583,7 @@ static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval
                        index = Z_LVAL_P(offset);
                }
                ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-               if (ht->nApplyCount > 0) {
+               if (ht->u.v.nApplyCount > 0) {
                        zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                        return;
                }
@@ -827,7 +827,7 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /*
                        ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);
                }
 
-               if (intern->debug_info->nApplyCount == 0) {
+               if (intern->debug_info->u.v.nApplyCount == 0) {
                        zend_hash_clean(intern->debug_info);
                        zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref);
 
@@ -1446,27 +1446,27 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
        *Z_ARRVAL(tmp) = *aht;
 
        if (!use_arg) {
-               aht->nApplyCount++;
+               aht->u.v.nApplyCount++;
                zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval, 1, &tmp, NULL TSRMLS_CC);
-               aht->nApplyCount--;
+               aht->u.v.nApplyCount--;
        } else if (use_arg == SPL_ARRAY_METHOD_MAY_USER_ARG) {
                if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arg) == FAILURE) {
                        zval_ptr_dtor(&tmp);
                        zend_throw_exception(spl_ce_BadMethodCallException, "Function expects one argument at most", 0 TSRMLS_CC);
                        return;
                }
-               aht->nApplyCount++;
+               aht->u.v.nApplyCount++;
                zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval, arg? 2 : 1, &tmp, arg TSRMLS_CC);
-               aht->nApplyCount--;
+               aht->u.v.nApplyCount--;
        } else {
                if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
                        zval_ptr_dtor(&tmp);
                        zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC);
                        return;
                }
-               aht->nApplyCount++;
+               aht->u.v.nApplyCount++;
                zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval, 2, &tmp, arg TSRMLS_CC);
-               aht->nApplyCount--;
+               aht->u.v.nApplyCount--;
        }
        /* A tricky way to pass "aht" by reference, copy back and cleanup */
        if (Z_ISREF(tmp) && Z_TYPE_P(Z_REFVAL(tmp))) {
index 6bc21ee814f15de7ed2d14d00fcd04bc131b95bc..dc10dde6e9bffdf759a94ae45f03b65519ebfe90 100644 (file)
@@ -514,7 +514,7 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp TSRML
                zend_hash_init(intern->debug_info, 1, NULL, ZVAL_PTR_DTOR, 0);
        }
 
-       if (intern->debug_info->nApplyCount == 0) {
+       if (intern->debug_info->u.v.nApplyCount == 0) {
 
                if (!intern->std.properties) {
                        rebuild_object_properties(&intern->std);
index 55550d6f4018b923e1db2f2133e8735fcee28b6c..f8ce102967818be19529cf92c7d27bec18942b7e 100644 (file)
@@ -524,7 +524,7 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
                ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);
        }
 
-       if (intern->debug_info->nApplyCount == 0) {
+       if (intern->debug_info->u.v.nApplyCount == 0) {
 
                zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref);
 
index 0b2eee69ebffc766e03c351781a8b79d5ad0437a..5abedecb7f873738f00da525539636c36f31bc35 100644 (file)
@@ -328,7 +328,7 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp TSRMLS_D
                ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(props) + 1, 0);
        }
 
-       if (intern->debug_info->nApplyCount == 0) {
+       if (intern->debug_info->u.v.nApplyCount == 0) {
                zend_hash_copy(intern->debug_info, props, (copy_ctor_func_t)zval_add_ref);
 
                array_init(&storage);
index 03c77fea80a68fd18e70c153b545bb3077127906..50d064f91ca8519b17fb9b135a682c4437244e52 100644 (file)
@@ -274,7 +274,7 @@ static int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
        zval *element;
 
        if (Z_TYPE_P(array) == IS_ARRAY) {
-               if (Z_ARRVAL_P(array)->nApplyCount > 1) {
+               if (Z_ARRVAL_P(array)->u.v.nApplyCount > 1) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
                        return 0;
                }
@@ -282,10 +282,10 @@ static int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
                cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
                if (mode == COUNT_RECURSIVE) {
                        ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), element) {
-                               Z_ARRVAL_P(array)->nApplyCount++;
+                               Z_ARRVAL_P(array)->u.v.nApplyCount++;
                                ZVAL_DEREF(element);
                                cnt += php_count_recursive(element, COUNT_RECURSIVE TSRMLS_CC);
-                               Z_ARRVAL_P(array)->nApplyCount--;
+                               Z_ARRVAL_P(array)->u.v.nApplyCount--;
                        } ZEND_HASH_FOREACH_END();
                }
        }
@@ -1089,7 +1089,7 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive
                                SEPARATE_ZVAL(zv);
                                thash = Z_ARRVAL_P(zv);
                        }
-                       if (thash->nApplyCount > 1) {
+                       if (thash->u.v.nApplyCount > 1) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
                                if (userdata) {
                                        zval_ptr_dtor(&args[2]);
@@ -1101,9 +1101,9 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive
                        orig_array_walk_fci = BG(array_walk_fci);
                        orig_array_walk_fci_cache = BG(array_walk_fci_cache);
 
-                       thash->nApplyCount++;
+                       thash->u.v.nApplyCount++;
                        php_array_walk(thash, userdata, recursive TSRMLS_CC);
-                       thash->nApplyCount--;
+                       thash->u.v.nApplyCount--;
 
                        /* restore the fcall info and cache */
                        BG(array_walk_fci) = orig_array_walk_fci;
@@ -1475,17 +1475,17 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu
                        zend_hash_update(Z_ARRVAL_P(return_value), Z_STR_P(entry), &data);
                }
        } else if (Z_TYPE_P(entry) == IS_ARRAY) {
-               if ((Z_ARRVAL_P(entry)->nApplyCount > 1)) {
+               if ((Z_ARRVAL_P(entry)->u.v.nApplyCount > 1)) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
                        return;
                }
 
-               Z_ARRVAL_P(entry)->nApplyCount++;
+               Z_ARRVAL_P(entry)->u.v.nApplyCount++;
 
                ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL_P(entry), value_ptr) {
                        php_compact_var(eg_active_symbol_table, return_value, value_ptr TSRMLS_CC);
                } ZEND_HASH_FOREACH_END();
-               Z_ARRVAL_P(entry)->nApplyCount--;
+               Z_ARRVAL_P(entry)->u.v.nApplyCount--;
        }
 }
 /* }}} */
@@ -1797,7 +1797,7 @@ static void php_array_data_shuffle(zval *array TSRMLS_DC) /* {{{ */
                p->key = NULL;
        }
        hash->nNextFreeElement = n_elems;
-       if (!(hash->flags & HASH_FLAG_PACKED)) {
+       if (!(hash->u.flags & HASH_FLAG_PACKED)) {
                zend_hash_to_packed(hash);
        }
        HANDLE_UNBLOCK_INTERRUPTIONS();
@@ -2037,7 +2037,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
                }
                Z_ARRVAL_P(stack)->nNextFreeElement = k;
                if (should_rehash) {
-                       if (Z_ARRVAL_P(stack)->flags & HASH_FLAG_PACKED) {
+                       if (Z_ARRVAL_P(stack)->u.flags & HASH_FLAG_PACKED) {
                                zend_hash_packed_to_hash(Z_ARRVAL_P(stack));
                        } else {
                                zend_hash_rehash(Z_ARRVAL_P(stack));
@@ -2272,7 +2272,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
                                ZVAL_DEREF(src_zval);
                                ZVAL_DEREF(dest_zval);
                                thash = Z_TYPE_P(dest_zval) == IS_ARRAY ? Z_ARRVAL_P(dest_zval) : NULL;
-                               if ((thash && thash->nApplyCount > 1) || (src_entry == dest_entry && Z_ISREF_P(dest_entry) && (Z_REFCOUNT_P(dest_entry) % 2))) {
+                               if ((thash && thash->u.v.nApplyCount > 1) || (src_entry == dest_entry && Z_ISREF_P(dest_entry) && (Z_REFCOUNT_P(dest_entry) % 2))) {
                                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
                                        return 0;
                                }
@@ -2303,16 +2303,16 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS
                                }
                                if (Z_TYPE_P(src_zval) == IS_ARRAY) {
                                        if (thash) {
-                                               thash->nApplyCount++;
+                                               thash->u.v.nApplyCount++;
                                        }
                                        if (!php_array_merge(Z_ARRVAL_P(dest_zval), Z_ARRVAL_P(src_zval), recursive TSRMLS_CC)) {
                                                if (thash) {
-                                                       thash->nApplyCount--;
+                                                       thash->u.v.nApplyCount--;
                                                }
                                                return 0;
                                        }
                                        if (thash) {
-                                               thash->nApplyCount--;
+                                               thash->u.v.nApplyCount--;
                                        }
                                } else {
                                        if (Z_REFCOUNTED_P(src_entry)) {
@@ -2377,24 +2377,24 @@ PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC
 
                dest_zval = dest_entry;
                ZVAL_DEREF(dest_zval);
-               if (Z_ARRVAL_P(dest_zval)->nApplyCount > 1 ||
-                   Z_ARRVAL_P(src_zval)->nApplyCount > 1 ||
+               if (Z_ARRVAL_P(dest_zval)->u.v.nApplyCount > 1 ||
+                   Z_ARRVAL_P(src_zval)->u.v.nApplyCount > 1 ||
                    (Z_ISREF_P(src_entry) && Z_ISREF_P(dest_entry) && Z_REF_P(src_entry) == Z_REF_P(dest_entry) && (Z_REFCOUNT_P(dest_entry) % 2))) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");
                        return 0;
                }
                SEPARATE_ZVAL(dest_zval);
-               Z_ARRVAL_P(dest_zval)->nApplyCount++;
-               Z_ARRVAL_P(src_zval)->nApplyCount++;
+               Z_ARRVAL_P(dest_zval)->u.v.nApplyCount++;
+               Z_ARRVAL_P(src_zval)->u.v.nApplyCount++;
                
 
                if (!php_array_replace_recursive(Z_ARRVAL_P(dest_zval), Z_ARRVAL_P(src_zval) TSRMLS_CC)) {
-                       Z_ARRVAL_P(dest_zval)->nApplyCount--;
-                       Z_ARRVAL_P(src_zval)->nApplyCount--;
+                       Z_ARRVAL_P(dest_zval)->u.v.nApplyCount--;
+                       Z_ARRVAL_P(src_zval)->u.v.nApplyCount--;
                        return 0;
                }
-               Z_ARRVAL_P(dest_zval)->nApplyCount--;
-               Z_ARRVAL_P(src_zval)->nApplyCount--;
+               Z_ARRVAL_P(dest_zval)->u.v.nApplyCount--;
+               Z_ARRVAL_P(src_zval)->u.v.nApplyCount--;
        } ZEND_HASH_FOREACH_END();
 
        return 1;
@@ -2883,7 +2883,7 @@ PHP_FUNCTION(array_unique)
        }
 
        /* create and sort array with pointers to the target_hash buckets */
-       arTmp = (struct bucketindex *) pemalloc((Z_ARRVAL_P(array)->nNumOfElements + 1) * sizeof(struct bucketindex), Z_ARRVAL_P(array)->flags & HASH_FLAG_PERSISTENT);
+       arTmp = (struct bucketindex *) pemalloc((Z_ARRVAL_P(array)->nNumOfElements + 1) * sizeof(struct bucketindex), Z_ARRVAL_P(array)->u.flags & HASH_FLAG_PERSISTENT);
        if (!arTmp) {
                zval_dtor(return_value);
                RETURN_FALSE;
@@ -2922,7 +2922,7 @@ PHP_FUNCTION(array_unique)
                        }
                }
        }
-       pefree(arTmp, Z_ARRVAL_P(array)->flags & HASH_FLAG_PERSISTENT);
+       pefree(arTmp, Z_ARRVAL_P(array)->u.flags & HASH_FLAG_PERSISTENT);
 }
 /* }}} */
 
@@ -3215,7 +3215,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
                        goto out;
                }
                hash = Z_ARRVAL(args[i]);
-               list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), hash->flags & HASH_FLAG_PERSISTENT);
+               list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), hash->u.flags & HASH_FLAG_PERSISTENT);
                if (!list) {
                        PHP_ARRAY_CMP_FUNC_RESTORE();
 
@@ -3352,7 +3352,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
 out:
        for (i = 0; i < arr_argc; i++) {
                hash = Z_ARRVAL(args[i]);
-               pefree(lists[i], hash->flags & HASH_FLAG_PERSISTENT);
+               pefree(lists[i], hash->u.flags & HASH_FLAG_PERSISTENT);
        }
 
        PHP_ARRAY_CMP_FUNC_RESTORE();
@@ -3635,7 +3635,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
                        goto out;
                }
                hash = Z_ARRVAL(args[i]);
-               list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), hash->flags & HASH_FLAG_PERSISTENT);
+               list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), hash->u.flags & HASH_FLAG_PERSISTENT);
                if (!list) {
                        PHP_ARRAY_CMP_FUNC_RESTORE();
 
@@ -3768,7 +3768,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
 out:
        for (i = 0; i < arr_argc; i++) {
                hash = Z_ARRVAL(args[i]);
-               pefree(lists[i], hash->flags & HASH_FLAG_PERSISTENT);
+               pefree(lists[i], hash->u.flags & HASH_FLAG_PERSISTENT);
        }
 
        PHP_ARRAY_CMP_FUNC_RESTORE();
@@ -4033,7 +4033,7 @@ PHP_FUNCTION(array_multisort)
 
                }
                hash->nNextFreeElement = array_size;
-               if (!(hash->flags & HASH_FLAG_PACKED)) {
+               if (!(hash->u.flags & HASH_FLAG_PACKED)) {
                        zend_hash_to_packed(hash);
                }
        }
index bf9a5a94db5a02edf1f46f5ce15fc3fad3d0d379..7647781e2ba2346037b875010c67d4cd062e12af 100644 (file)
@@ -3760,9 +3760,7 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */
        BG(page_inode) = -1;
        BG(page_mtime) = -1;
 #ifdef HAVE_PUTENV
-       if (zend_hash_init(&BG(putenv_ht), 1, NULL, php_putenv_destructor, 0) == FAILURE) {
-               return FAILURE;
-       }
+       zend_hash_init(&BG(putenv_ht), 1, NULL, php_putenv_destructor, 0);
 #endif
        BG(user_shutdown_function_names) = NULL;
 
index ef49ee4d10f22179f49769f934c491732cdb1234..186c30cc902f584250c5d9520f1d606e2138bd5a 100644 (file)
@@ -139,7 +139,7 @@ static void convert_browscap_pattern(zval *pattern, int persistent) /* {{{ */
 static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC) /* {{{ */
 {
        browser_data *bdata = arg;
-       int persistent = bdata->htab->flags & HASH_FLAG_PERSISTENT;
+       int persistent = bdata->htab->u.flags & HASH_FLAG_PERSISTENT;
        
        if (!arg1) {
                return;
@@ -232,14 +232,10 @@ static int browscap_read_file(char *filename, browser_data *browdata, int persis
                return FAILURE;
        }
 
-       if (zend_hash_init_ex(browdata->htab, 0, NULL,
+       zend_hash_init_ex(browdata->htab, 0, NULL,
                        (dtor_func_t) (persistent?browscap_entry_dtor_persistent
                                                                         :browscap_entry_dtor_request),
-                       persistent, 0) == FAILURE) {
-               pefree(browdata->htab, persistent);
-               browdata->htab = NULL;
-               return FAILURE;
-       }
+                       persistent, 0);
 
        fh.handle.fp = VCWD_FOPEN(filename, "r");
        fh.opened_path = NULL;
index b839a4cb97318d16ac3ca96efb7c3ddb309870a7..14d73779a4f424fb86af6214dcc5f0afecf2a043 100644 (file)
@@ -41,7 +41,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
                return FAILURE;
        }
 
-       if (ht->nApplyCount > 0) {
+       if (ht->u.v.nApplyCount > 0) {
                /* Prevent recursion */
                return SUCCESS;
        }
@@ -134,9 +134,9 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
                                *(p++) = 'B';
                                *p = '\0';
                        }
-                       ht->nApplyCount++;
+                       ht->u.v.nApplyCount++;
                        php_url_encode_hash_ex(HASH_OF(zdata), formstr, NULL, 0, newprefix, newprefix_len, "%5D", 3, (Z_TYPE_P(zdata) == IS_OBJECT ? zdata : NULL), arg_sep, enc_type TSRMLS_CC);
-                       ht->nApplyCount--;
+                       ht->u.v.nApplyCount--;
                        efree(newprefix);
                } else if (Z_TYPE_P(zdata) == IS_NULL || Z_TYPE_P(zdata) == IS_RESOURCE) {
                        /* Skip these types */
index 4ecdd09dd74a5bbb9af5f1210a0d7dec70ace03e..2dc13f40122218618ccf745e7459443bb435ec82 100644 (file)
@@ -59,7 +59,7 @@ do  { \
        /* fprintf(stderr, "SERIALIZE_INIT      == lock: %u, level: %u\n", BG(serialize_lock), BG(serialize).level); */ \
        if (BG(serialize_lock) || !BG(serialize).level) { \
                ALLOC_HASHTABLE(var_hash_ptr); \
-               zend_hash_init((var_hash_ptr), 10, NULL, NULL, 0); \
+               zend_hash_init((var_hash_ptr), 16, NULL, NULL, 0); \
                if (!BG(serialize_lock)) { \
                        BG(serialize).var_hash = (void *)(var_hash_ptr); \
                        BG(serialize).level = 1; \
index 762b65387a30c8dbcfe33d6896a45d128c1c69e5..b0811d8c4f7b4d830511692e79d171c04cf835f8 100644 (file)
@@ -578,7 +578,7 @@ PHP_FUNCTION(stream_filter_register)
 
        if (!BG(user_filter_map)) {
                BG(user_filter_map) = (HashTable*) emalloc(sizeof(HashTable));
-               zend_hash_init(BG(user_filter_map), 5, NULL, (dtor_func_t) filter_item_dtor, 0);
+               zend_hash_init(BG(user_filter_map), 8, NULL, (dtor_func_t) filter_item_dtor, 0);
        }
 
        fdat = ecalloc(1, sizeof(struct php_user_filter_data));
index a4e556abdc02a918efd919417f982acee2195933..3dbd71abd548371fa0b3939c13da40dfceae20ba 100644 (file)
@@ -148,9 +148,9 @@ again:
                        break;
                case IS_ARRAY:
                        myht = Z_ARRVAL_P(struc);
-                       if (++myht->nApplyCount > 1) {
+                       if (++myht->u.v.nApplyCount > 1) {
                                PUTS("*RECURSION*\n");
-                               --myht->nApplyCount;
+                               --myht->u.v.nApplyCount;
                                return;
                        }
                        php_printf("%sarray(%d) {\n", COMMON, zend_hash_num_elements(myht));
@@ -159,9 +159,9 @@ again:
                        goto head_done;
                case IS_OBJECT:
                        myht = Z_OBJDEBUG_P(struc, is_temp);
-                       if (myht && ++myht->nApplyCount > 1) {
+                       if (myht && ++myht->u.v.nApplyCount > 1) {
                                PUTS("*RECURSION*\n");
-                               --myht->nApplyCount;
+                               --myht->u.v.nApplyCount;
                                return;
                        }
 
@@ -176,7 +176,7 @@ again:
        head_done:
                        if (myht) {
                                zend_hash_apply_with_arguments(myht TSRMLS_CC, (apply_func_args_t) php_element_dump_func, 1, level);
-                               --myht->nApplyCount;
+                               --myht->u.v.nApplyCount;
                                if (is_temp) {
                                        zend_hash_destroy(myht);
                                        efree(myht);
@@ -323,7 +323,7 @@ again:
                break;
        case IS_ARRAY:
                myht = Z_ARRVAL_P(struc);
-               if (myht->nApplyCount > 1) {
+               if (myht->u.v.nApplyCount > 1) {
                        PUTS("*RECURSION*\n");
                        return;
                }
@@ -332,7 +332,7 @@ again:
                goto head_done;
        case IS_OBJECT:
                myht = Z_OBJDEBUG_P(struc, is_temp);
-               if (myht && myht->nApplyCount > 1) {
+               if (myht && myht->u.v.nApplyCount > 1) {
                        PUTS("*RECURSION*\n");
                        return;
                }
@@ -522,7 +522,7 @@ again:
                        break;
                case IS_ARRAY:
                        myht = Z_ARRVAL_P(struc);
-                       if (myht->nApplyCount > 0){
+                       if (myht->u.v.nApplyCount > 0){
                                smart_str_appendl(buf, "NULL", 4);
                                zend_error(E_WARNING, "var_export does not handle circular references");
                                return;
@@ -543,7 +543,7 @@ again:
 
                case IS_OBJECT:
                        myht = Z_OBJPROP_P(struc);
-                       if(myht && myht->nApplyCount > 0){
+                       if(myht && myht->u.v.nApplyCount > 0){
                                smart_str_appendl(buf, "NULL", 4);
                                zend_error(E_WARNING, "var_export does not handle circular references");
                                return;
@@ -961,16 +961,16 @@ again:
                                        /* we should still add element even if it's not OK,
                                         * since we already wrote the length of the array before */
                                        if ((Z_TYPE_P(data) == IS_ARRAY && Z_TYPE_P(struc) == IS_ARRAY && Z_ARR_P(data) == Z_ARR_P(struc))
-                                               || (Z_TYPE_P(data) == IS_ARRAY && Z_ARRVAL_P(data)->nApplyCount > 1)
+                                               || (Z_TYPE_P(data) == IS_ARRAY && Z_ARRVAL_P(data)->u.v.nApplyCount > 1)
                                        ) {
                                                smart_str_appendl(buf, "N;", 2);
                                        } else {
                                                if (Z_TYPE_P(data) == IS_ARRAY) {
-                                                       Z_ARRVAL_P(data)->nApplyCount++;
+                                                       Z_ARRVAL_P(data)->u.v.nApplyCount++;
                                                }
                                                php_var_serialize_intern(buf, data, var_hash TSRMLS_CC);
                                                if (Z_TYPE_P(data) == IS_ARRAY) {
-                                                       Z_ARRVAL_P(data)->nApplyCount--;
+                                                       Z_ARRVAL_P(data)->u.v.nApplyCount--;
                                                }
                                        }
                                } ZEND_HASH_FOREACH_END();
index 2b8b1826da571e50246c3c728dc5fe8316bbde0f..9cacbd4b4bef2286c173ed17d0de9c902d15f3c0 100644 (file)
@@ -65,7 +65,7 @@ static void _type_dtor(zval *zv)
 static void sapi_globals_ctor(sapi_globals_struct *sapi_globals TSRMLS_DC)
 {
        memset(sapi_globals, 0, sizeof(*sapi_globals));
-       zend_hash_init_ex(&sapi_globals->known_post_content_types, 5, NULL, _type_dtor, 1, 0);
+       zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0);
        php_setup_sapi_content_types(TSRMLS_C);
 }
 
index 13cea0a8f88c94595c6dfcdaab1e45156175d3dd..cbf1fed9f0338efe5a2b44937dab0e5136c5f2a3 100644 (file)
@@ -137,9 +137,9 @@ static void reverse_conflict_dtor(zval *zv)
 PHPAPI void php_output_startup(void)
 {
        ZEND_INIT_MODULE_GLOBALS(output, php_output_init_globals, NULL);
-       zend_hash_init(&php_output_handler_aliases, 0, NULL, NULL, 1);
-       zend_hash_init(&php_output_handler_conflicts, 0, NULL, NULL, 1);
-       zend_hash_init(&php_output_handler_reverse_conflicts, 0, NULL, reverse_conflict_dtor, 1);
+       zend_hash_init(&php_output_handler_aliases, 8, NULL, NULL, 1);
+       zend_hash_init(&php_output_handler_conflicts, 8, NULL, NULL, 1);
+       zend_hash_init(&php_output_handler_reverse_conflicts, 8, NULL, reverse_conflict_dtor, 1);
        php_output_direct = php_output_stdout;
 }
 /* }}} */
@@ -636,7 +636,7 @@ PHPAPI int php_output_handler_reverse_conflict_register(const char *name, size_t
        if (SUCCESS == (rev_ptr = zend_hash_str_find_ptr(&php_output_handler_reverse_conflicts, name, name_len))) {
                return zend_hash_next_index_insert_ptr(rev_ptr, check_func) ? SUCCESS : FAILURE;
        } else {
-               zend_hash_init(&rev, 1, NULL, NULL, 1);
+               zend_hash_init(&rev, 8, NULL, NULL, 1);
                if (SUCCESS != zend_hash_next_index_insert_ptr(&rev, check_func)) {
                        zend_hash_destroy(&rev);
                        return FAILURE;
index 024dbe682194bb15e18a00207d5d867fa1d5ac8b..ed7da808f76b9ac5554dc235af853e3989c938cc 100644 (file)
@@ -262,7 +262,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
                                /* If option not found in hash or is not an array -> create array, otherwise add to existing array */
                                if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) {
                                        ZVAL_NEW_PERSISTENT_ARR(&option_arr);
-                                       zend_hash_init(Z_ARRVAL(option_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1);
+                                       zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1);
                                        find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr);
                                }
 
@@ -329,7 +329,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
                                                zval section_arr;
 
                                                ZVAL_NEW_PERSISTENT_ARR(&section_arr);
-                                               zend_hash_init(Z_ARRVAL(section_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1);
+                                               zend_hash_init(Z_ARRVAL(section_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1);
                                                entry = zend_hash_str_update(target_hash, key, key_len, &section_arr);
                                        }
                                        active_ini_hash = Z_ARRVAL_P(entry);
@@ -385,9 +385,7 @@ int php_init_config(TSRMLS_D)
        int free_ini_search_path = 0;
        zend_file_handle fh;
 
-       if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) config_zval_dtor, 1) == FAILURE) {
-               return FAILURE;
-       }
+       zend_hash_init(&configuration_hash, 8, NULL, (dtor_func_t) config_zval_dtor, 1);
 
        if (sapi_module.ini_defaults) {
                sapi_module.ini_defaults(&configuration_hash);
index 5acebd5b5b6291b3d96e337f1c0a1cbe499f8765..98a29f1e395803e92b7233f5f0ee8f5bdc682455 100644 (file)
@@ -762,10 +762,10 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
        }
 
        /* Initialize $_FILES[] */
-       zend_hash_init(&PG(rfc1867_protected_variables), 5, NULL, NULL, 0);
+       zend_hash_init(&PG(rfc1867_protected_variables), 8, NULL, NULL, 0);
 
        ALLOC_HASHTABLE(uploaded_files);
-       zend_hash_init(uploaded_files, 5, NULL, free_filename, 0);
+       zend_hash_init(uploaded_files, 8, NULL, free_filename, 0);
        SG(rfc1867_uploaded_files) = uploaded_files;
 
        array_init(&PG(http_globals)[TRACK_VARS_FILES]);
index 553404dc3c2c82f37e0c957f1385c6c94c2ca0e9..7ab74c7c08c284e332b528f6ade1eda695a586e2 100644 (file)
@@ -1648,14 +1648,11 @@ int php_init_stream_wrappers(int module_number TSRMLS_DC)
        /* Filters are cleaned up by the streams they're attached to */
        le_stream_filter = zend_register_list_destructors_ex(NULL, NULL, "stream filter", module_number);
 
-       return (
-                       zend_hash_init(&url_stream_wrappers_hash, 0, NULL, NULL, 1) == SUCCESS
-                       &&
-                       zend_hash_init(php_get_stream_filters_hash_global(), 0, NULL, NULL, 1) == SUCCESS
-                       &&
-                       zend_hash_init(php_stream_xport_get_hash(), 0, NULL, NULL, 1) == SUCCESS
-                       &&
-                       php_stream_xport_register("tcp", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
+       zend_hash_init(&url_stream_wrappers_hash, 8, NULL, NULL, 1);
+       zend_hash_init(php_get_stream_filters_hash_global(), 8, NULL, NULL, 1);
+       zend_hash_init(php_stream_xport_get_hash(), 8, NULL, NULL, 1);
+
+       return (php_stream_xport_register("tcp", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
                        &&
                        php_stream_xport_register("udp", php_stream_generic_socket_factory TSRMLS_CC) == SUCCESS
 #if defined(AF_UNIX) && !(defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE))
index 6384c66bca6975206fb4845d038bc571b902a4bd..f3e9dd6f0f893184e70d55fada9a3aa31ecfda20 100644 (file)
@@ -234,7 +234,7 @@ static void print_modules(TSRMLS_D)
 {
        HashTable sorted_registry;
 
-       zend_hash_init(&sorted_registry, 50, NULL, NULL, 1);
+       zend_hash_init(&sorted_registry, 64, NULL, NULL, 1);
 //???  zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
        zend_hash_copy(&sorted_registry, &module_registry, NULL);
        zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
@@ -756,7 +756,7 @@ static void php_cgi_ini_activate_user_config(char *path, int path_len, const cha
                new_entry = pemalloc(sizeof(user_config_cache_entry), 1);
                new_entry->expires = 0;
                new_entry->user_config = (HashTable *) pemalloc(sizeof(HashTable), 1);
-               zend_hash_init(new_entry->user_config, 0, NULL, (dtor_func_t) config_zval_dtor, 1);
+               zend_hash_init(new_entry->user_config, 8, NULL, (dtor_func_t) config_zval_dtor, 1);
                entry = zend_hash_str_update_ptr(&CGIG(user_config_cache), path, path_len, new_entry);
        }
 
@@ -1475,7 +1475,7 @@ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_
 #ifdef PHP_WIN32
        php_cgi_globals->impersonate = 0;
 #endif
-       zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1);
+       zend_hash_init(&php_cgi_globals->user_config_cache, 8, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1);
 }
 /* }}} */
 
index a5845d9f8d1ecb2d77e502e2a62a02c11c3bd3de..585b6b8e878884bc0aefcd4f086fd0af68cf0501 100644 (file)
@@ -411,7 +411,7 @@ int fcgi_init(void)
                sa_t sa;
                socklen_t len = sizeof(sa);
 #endif
-               zend_hash_init(&fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 1);
+               zend_hash_init(&fcgi_mgmt_vars, 8, NULL, fcgi_free_mgmt_var_cb, 1);
                fcgi_set_mgmt_var("FCGI_MPXS_CONNS", sizeof("FCGI_MPXS_CONNS")-1, "0", sizeof("0")-1);
 
                is_initialized = 1;