From: Xinchen Hui Date: Sun, 16 Feb 2014 14:27:31 +0000 (+0800) Subject: Use better data structures (incomplete) X-Git-Tag: POST_PHPNG_MERGE~412^2~642 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad1838d2483c3a44c77a2d483a5cf27ffeb63e45;p=php Use better data structures (incomplete) --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 5ef386b04a..903ca7882f 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -149,7 +149,7 @@ SPL_API int spl_hash_verify_pos(spl_array_object * intern TSRMLS_DC) /* {{{ */ /* }}} */ /* {{{ spl_array_object_free_storage */ -static void spl_array_object_free_storage(void *object TSRMLS_DC) +static void spl_array_object_free_storage(zend_object *object TSRMLS_DC) { spl_array_object *intern = (spl_array_object *)object; @@ -1297,7 +1297,7 @@ SPL_METHOD(Array, getIterator) ZVAL_OBJ(return_value, spl_array_object_new_ex(intern->ce_get_iterator, object, 0 TSRMLS_CC)); Z_SET_REFCOUNT_P(return_value, 1); - Z_SET_ISREF_P(return_value); + //!!!PZ_SET_ISREF_P(return_value); } /* }}} */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 1233436ada..f2093d9cb4 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -294,7 +294,8 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu } if (!ZVAL_IS_UNDEF(&intern->u.file.zcontext)) { - zend_list_addref(Z_RESVAL_P(intern->u.file.zcontext)); + //zend_list_addref(Z_RES_VAL(intern->u.file.zcontext)); + Z_ADDREF_P(&intern->u.file.zcontext); } if (intern->file_name_len > 1 && IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) { @@ -307,8 +308,10 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu intern->u.file.open_mode = estrndup(intern->u.file.open_mode, intern->u.file.open_mode_len); /* avoid reference counting in debug mode, thus do it manually */ - ZVAL_RESOURCE(&intern->u.file.zresource, php_stream_get_resource_id(intern->u.file.stream)); + ZVAL_RES(&intern->u.file.zresource, intern->u.file.stream->res); + /*!!! TODO: maybe bug? Z_SET_REFCOUNT(intern->u.file.zresource, 1); + */ intern->u.file.delimiter = ','; intern->u.file.enclosure = '"'; diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c index 1787f28e1e..3d12b04799 100644 --- a/ext/spl/spl_engine.c +++ b/ext/spl/spl_engine.c @@ -36,7 +36,7 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) { object_init_ex(object, pce); Z_SET_REFCOUNT_P(object, 1); - Z_SET_ISREF_P(object); /* check if this can be hold always */ + // !!!PZ_SET_ISREF_P(object); /* check if this can be hold always */ } /* }}} */ diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 3c35dc77c2..075df9b2b7 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -601,7 +601,7 @@ SPL_METHOD(SplFixedArray, __wakeup) spl_fixedarray_init(intern->array, size TSRMLS_CC); for (zend_hash_internal_pointer_reset_ex(intern_ht, &ptr); (data = zend_hash_get_current_data_ex(intern_ht, &ptr)) != NULL; zend_hash_move_forward_ex(intern_ht, &ptr)) { - Z_ADDREF_PP(data); + Z_ADDREF_P(data); ZVAL_COPY_VALUE(&intern->array->elements[index++], data); } diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c index 6b5a612637..e3cf1323c3 100644 --- a/ext/spl/spl_functions.c +++ b/ext/spl/spl_functions.c @@ -77,16 +77,16 @@ void spl_register_property( zend_class_entry * class_entry, char *prop_name, int /* }}} */ /* {{{ spl_add_class_name */ -void spl_add_class_name(zval *list, zend_class_entry * pce, int allow, int ce_flags TSRMLS_DC) +void spl_add_class_name(zval *list, zend_class_entry *pce, int allow, int ce_flags TSRMLS_DC) { if (!allow || (allow > 0 && pce->ce_flags & ce_flags) || (allow < 0 && !(pce->ce_flags & ce_flags))) { zval *tmp; if ((tmp = zend_hash_find(Z_ARRVAL_P(list), pce->name)) == NULL) { - MAKE_STD_ZVAL(tmp); + zval t; STR_ADDREF(pce->name); - ZVAL_STR(tmp, pce->name); - zend_hash_add(Z_ARRVAL_P(list), pce->name, tmp); + ZVAL_STR(&t, pce->name); + zend_hash_add(Z_ARRVAL_P(list), pce->name, &t); } } }