cvs: ZendEngine2 / zend_objects.c

From: Date: Tue, 01 Jul 2003 23:29:36 +0000
Subject: cvs: ZendEngine2 / zend_objects.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1427@lists.php.net to get a copy of this message
helly Tue Jul 1 19:29:36 2003 EDT Modified files: /ZendEngine2 zend_objects.c Log: Fix __clone(). # This is somewhat discussable. I copied all properties from the old to the # new object. But for type correctness we only need to copy the properties # declared in the class and its parents. # # Also someone might want to take care about static and const members. Index: ZendEngine2/zend_objects.c diff -u ZendEngine2/zend_objects.c:1.30 ZendEngine2/zend_objects.c:1.31 --- ZendEngine2/zend_objects.c:1.30 Tue Jul 1 15:13:50 2003 +++ ZendEngine2/zend_objects.c Tue Jul 1 19:29:36 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_objects.c,v 1.30 2003/07/01 19:13:50 helly Exp $ */ +/* $Id: zend_objects.c,v 1.31 2003/07/01 23:29:36 helly Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -111,6 +111,10 @@ old_object = zend_objects_get_address(zobject TSRMLS_CC); retval = zend_objects_new(&new_object, old_object->ce TSRMLS_CC); + ALLOC_HASHTABLE(new_object->properties); + zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *)); + if (old_object->ce->clone) { zval *old_obj; zval *new_obj; @@ -135,9 +139,6 @@ clone_func_name->value.str.val = estrndup("__clone", sizeof("__clone")-1); clone_func_name->value.str.len = sizeof("__clone")-1; - ALLOC_HASHTABLE(new_object->properties); - zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); - ZEND_INIT_SYMTABLE(&symbol_table); ZEND_SET_SYMBOL(&symbol_table, "that", old_obj); @@ -147,10 +148,6 @@ zval_ptr_dtor(&new_obj); zval_ptr_dtor(&clone_func_name); zval_ptr_dtor(&retval_ptr); - } else { - ALLOC_HASHTABLE(new_object->properties); - zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *)); } return retval;

« previous php.zend-engine.cvs (#1427) next »