]> granicus.if.org Git - php/commitdiff
Fixed object creating (std_init calls store_put now)
authorXinchen Hui <laruence@gmail.com>
Thu, 27 Feb 2014 14:47:30 +0000 (22:47 +0800)
committerXinchen Hui <laruence@gmail.com>
Thu, 27 Feb 2014 14:47:30 +0000 (22:47 +0800)
ext/spl/spl_array.c
ext/spl/spl_directory.c
ext/spl/spl_dllist.c
ext/spl/spl_fixedarray.c
ext/spl/spl_heap.c
ext/spl/spl_iterators.c
ext/spl/spl_observer.c

index 6564e0832bf82bf90d478f9bcfd22486d6cd689f..924423122248d5d5f9162d2f307d811e719f63ec 100644 (file)
@@ -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);
index f8ec9efc49df0152708cced5e942ffac52dda1e9..19edadd1bf2ea5fc2b20225ab02f196eaeb8fd1c 100644 (file)
@@ -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;
 }
index 12aa2b42b9874b108c2ec84c3103b15bbc921712..28b2f8e89a96d331fcf06a2adc13e18bde51cc6c 100644 (file)
@@ -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");
        }
index 5d419898be13a0ea9d65fef69ed79aafed43beff..758eec3e1615e2e64e3f32d3b3ac7cf449572b05 100644 (file)
@@ -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");
        }
index 8523978584a41e8678a862a10b586dec2aed3d3b..f74b1d4a10ad8596c75594437fdfbe3f7b45e3f4 100644 (file)
@@ -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");
        }
index 5a621bab09e2f8415e6ede709c6a840060f1ebef..f4575d8350fb7d5bb264135b5c9302d197f7268d 100644 (file)
@@ -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;
 }
index 411fed6812251013cc8a658634a7e197a775ee2e..19037323ec23d69d96bfb44ca64de949a39de37d 100644 (file)
@@ -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) {