]> granicus.if.org Git - php/commitdiff
Fix zend_initialize_class_data()
authorZeev Suraski <zeev@php.net>
Mon, 10 Feb 2003 16:46:05 +0000 (16:46 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 10 Feb 2003 16:46:05 +0000 (16:46 +0000)
Zend/zend_compile.c

index da44ebab27d518fc383a0fea034372ddf30dce78..d273ed9870f273a988710f741c5282ec055c75a2 100644 (file)
@@ -3161,17 +3161,24 @@ void zend_destroy_property_info(zend_property_info *property_info)
 
 void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers)
 {
+       zend_bool persistent_hashes = (ce->type == ZEND_INTERNAL_CLASS) ? 1 : 0;
+
        ce->refcount = 1;
        ce->constants_updated = 0;
        ce->ce_flags = 0;
 
-       zend_hash_init_ex(&ce->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
-       zend_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) zend_destroy_property_info, 1, 0);
-       ce->static_members = (HashTable *) malloc(sizeof(HashTable));
-       zend_hash_init_ex(ce->static_members, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
-       zend_hash_init_ex(&ce->constants_table, 0, NULL, ZVAL_PTR_DTOR, 1, 0);
-       zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, 1, 0);
-       zend_hash_init_ex(&ce->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, 0);
+       zend_hash_init_ex(&ce->default_properties, 0, NULL, ZVAL_PTR_DTOR, persistent_hashes, 0);
+       zend_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) zend_destroy_property_info, persistent_hashes, 0);
+
+       if (persistent_hashes) {
+               ce->static_members = (HashTable *) malloc(sizeof(HashTable));
+       } else {
+               ALLOC_HASHTABLE(ce->static_members);
+       }
+       zend_hash_init_ex(ce->static_members, 0, NULL, ZVAL_PTR_DTOR, persistent_hashes, 0);
+       zend_hash_init_ex(&ce->constants_table, 0, NULL, ZVAL_PTR_DTOR, persistent_hashes, 0);
+       zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0);
+       zend_hash_init_ex(&ce->class_table, 10, NULL, ZEND_CLASS_DTOR, persistent_hashes, 0);
 
        if (nullify_handlers) {
                ce->constructor = NULL;