cvs: php4 /ext/standard aggregation.c

From: Date: Wed, 13 Mar 2002 02:14:28 +0000
Subject: cvs: php4 /ext/standard aggregation.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10048@lists.php.net to get a copy of this message
wez Tue Mar 12 21:14:28 2002 EDT Modified files: /php4/ext/standard aggregation.c Log: Fix some issues with ZE2, but now have some leaks. # Any ideas Andrei? Index: php4/ext/standard/aggregation.c diff -u php4/ext/standard/aggregation.c:1.4 php4/ext/standard/aggregation.c:1.5 --- php4/ext/standard/aggregation.c:1.4 Tue Mar 12 15:28:17 2002 +++ php4/ext/standard/aggregation.c Tue Mar 12 21:14:28 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: aggregation.c,v 1.4 2002/03/12 20:28:17 andi Exp $ */ +/* $Id: aggregation.c,v 1.5 2002/03/13 02:14:28 wez Exp $ */ #include "php.h" #include "basic_functions.h" @@ -30,10 +30,15 @@ /* FIXME: This is here to make it compile with Engine 2 but part of this module will need rewriting */ #ifndef ZEND_ENGINE_2 destroy_zend_class(info->new_ce); + efree(info->new_ce); #else - destroy_zend_class(&info->new_ce); + /* FIXME: In ZE2, this dtor is called prior to deleting the objects, + * which causes this new_ce to be destroyed twice (which is bad news). + * Skipping deleting it here will prevent a segfault but will leak + * the class name, the static_members hash and the ce itself */ + + /* destroy_zend_class(&info->new_ce); */ #endif - efree(info->new_ce); zval_ptr_dtor(&info->aggr_members); } @@ -316,6 +321,9 @@ efree(class_name_lc); return; } +#ifdef ZEND_ENGINE_2 + ce = *(zend_class_entry**)ce; +#endif /* * And God said, Let there be light; and there was light. But only once. @@ -351,6 +359,23 @@ zend_hash_init(&new_ce->default_properties, 10, NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(&new_ce->function_table, &Z_OBJCE_P(obj)->function_table, (copy_ctor_func_t) function_add_ref, &tmp_zend_function, sizeof(zend_function)); zend_hash_copy(&new_ce->default_properties, &Z_OBJCE_P(obj)->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + +#ifdef ZEND_ENGINE_2 + ALLOC_HASHTABLE(new_ce->static_members); + zend_hash_init(new_ce->static_members, 10, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(new_ce->static_members, Z_OBJCE_P(obj)->static_members, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + zend_hash_init(&new_ce->constants_table, 10, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(&new_ce->constants_table, &Z_OBJCE_P(obj)->constants_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + zend_hash_init(&new_ce->class_table, 10, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(&new_ce->class_table, &Z_OBJCE_P(obj)->class_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + + zend_hash_init(&new_ce->private_properties, 10, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(&new_ce->private_properties, &Z_OBJCE_P(obj)->private_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + + new_ce->constructor = Z_OBJCE_P(obj)->constructor; + new_ce->destructor = Z_OBJCE_P(obj)->destructor; + new_ce->clone = Z_OBJCE_P(obj)->clone; +#endif new_ce->builtin_functions = Z_OBJCE_P(obj)->builtin_functions; new_ce->handle_function_call = Z_OBJCE_P(obj)->handle_function_call; new_ce->handle_property_get = Z_OBJCE_P(obj)->handle_property_get;

« previous php.cvs (#10048) next »