From: Xinchen Hui Date: Thu, 27 Feb 2014 14:47:30 +0000 (+0800) Subject: Fixed object creating (std_init calls store_put now) X-Git-Tag: POST_PHPNG_MERGE~412^2~500 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0817cee16431c06d8ea11d1231cfcd19a28ec526;p=php Fixed object creating (std_init calls store_put now) --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 6564e0832b..9244231222 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -155,8 +155,8 @@ static void spl_array_object_free_storage(zend_object *object TSRMLS_DC) zend_object_std_dtor(&intern->std TSRMLS_CC); - zval_ptr_dtor(&intern->array); - zval_ptr_dtor(&intern->retval); + zval_dtor(&intern->array); + zval_dtor(&intern->retval); if (intern->debug_info != NULL) { zend_hash_destroy(intern->debug_info); @@ -210,7 +210,6 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * intern->ar_flags &= ~SPL_ARRAY_IS_REF; } - zend_objects_store_put(&intern->std TSRMLS_CC); while (parent) { if (parent == spl_ce_ArrayIterator || parent == spl_ce_RecursiveArrayIterator) { intern->std.handlers = &spl_handler_ArrayIterator; @@ -959,19 +958,12 @@ static int spl_array_next(spl_array_object *intern TSRMLS_DC) /* {{{ */ } /* }}} */ -/* define an overloaded iterator structure */ -typedef struct { - zend_user_iterator intern; -} spl_array_it; - static void spl_array_it_dtor(zend_object_iterator *iter TSRMLS_DC) /* {{{ */ { - spl_array_it *iterator = (spl_array_it *)iter; - zend_user_it_invalidate_current(iter TSRMLS_CC); - zval_ptr_dtor(&iterator->intern.it.data); + zval_ptr_dtor(&iter->data); - efree(iterator); + efree(iter); } /* }}} */ @@ -1135,23 +1127,23 @@ zend_object_iterator_funcs spl_array_it_funcs = { zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC) /* {{{ */ { - spl_array_it *iterator; + zend_user_iterator *iterator; spl_array_object *array_object = (spl_array_object*)Z_OBJ_P(object); if (by_ref && (array_object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT)) { zend_error(E_ERROR, "An iterator cannot be used with foreach by reference"); } - iterator = emalloc(sizeof(spl_array_it)); + iterator = emalloc(sizeof(zend_user_iterator)); - zend_iterator_init((zend_object_iterator*)iterator TSRMLS_CC); + zend_iterator_init(&iterator->it TSRMLS_CC); - ZVAL_COPY(&iterator->intern.it.data, object); - iterator->intern.it.funcs = &spl_array_it_funcs; - iterator->intern.ce = ce; - ZVAL_UNDEF(&iterator->intern.value); + ZVAL_COPY(&iterator->it.data, object); + iterator->it.funcs = &spl_array_it_funcs; + iterator->ce = ce; + ZVAL_UNDEF(&iterator->value); - return (zend_object_iterator*)iterator; + return &iterator->it; } /* }}} */ @@ -1915,8 +1907,8 @@ PHP_MINIT_FUNCTION(spl_array) spl_handler_ArrayObject.unset_property = spl_array_unset_property; spl_handler_ArrayObject.compare_objects = spl_array_compare_objects; - spl_handler_ArrayObject.free_obj = spl_array_object_free_storage; spl_handler_ArrayObject.dtor_obj = zend_objects_destroy_object; + spl_handler_ArrayObject.free_obj = spl_array_object_free_storage; REGISTER_SPL_STD_CLASS_EX(ArrayIterator, spl_array_object_new, spl_funcs_ArrayIterator); REGISTER_SPL_IMPLEMENTS(ArrayIterator, Iterator); diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index f8ec9efc49..19edadd1bf 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -159,7 +159,6 @@ static zend_object *spl_filesystem_object_new_ex(zend_class_entry *class_type TS zend_object_std_init(&intern->std, class_type TSRMLS_CC); object_properties_init(&intern->std, class_type); - zend_objects_store_put(&intern->std TSRMLS_CC); intern->std.handlers = &spl_filesystem_object_handlers; return &intern->std; } diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 12aa2b42b9..28b2f8e89a 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -420,8 +420,6 @@ static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval inherited = 1; } - zend_objects_store_put(&intern->std); - if (!parent) { /* this must never happen */ php_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplDoublyLinkedList"); } diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 5d419898be..758eec3e16 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -246,8 +246,6 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z inherited = 1; } - zend_objects_store_put(&intern->std); - if (!parent) { /* this must never happen */ php_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplFixedArray"); } diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 8523978584..f74b1d4a10 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -439,8 +439,6 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o inherited = 1; } - zend_objects_store_put(&intern->std); - if (!parent) { /* this must never happen */ php_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplHeap"); } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 5a621bab09..f4575d8350 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -907,7 +907,6 @@ static zend_object *spl_RecursiveIteratorIterator_new_ex(zend_class_entry *class zend_object_std_init(&intern->std, class_type TSRMLS_CC); object_properties_init(&intern->std, class_type); - zend_objects_store_put(&intern->std TSRMLS_CC); intern->std.handlers = &spl_handlers_rec_it_it; return &intern->std; } @@ -2272,7 +2271,6 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type TSRMLS_DC) zend_object_std_init(&intern->std, class_type TSRMLS_CC); object_properties_init(&intern->std, class_type); - zend_objects_store_put(&intern->std TSRMLS_CC); intern->std.handlers = &spl_handlers_dual_it; return &intern->std; } diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 411fed6812..19037323ec 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -253,7 +253,6 @@ static zend_object *spl_object_storage_new_ex(zend_class_entry *class_type, zval zend_hash_init(&intern->storage, 0, NULL, spl_object_storage_dtor, 0); - zend_objects_store_put(&intern->std TSRMLS_CC); intern->std.handlers = &spl_handler_SplObjectStorage; if (orig) {