Replace ZVAL_COPY() and ZVAL_COPY_VALUE() for IS_OBJECT by cheaper macros

This commit is contained in:
Dmitry Stogov 2019-05-28 20:10:02 +03:00
parent 071b389bc6
commit 83804519df
29 changed files with 102 additions and 63 deletions

View File

@ -742,7 +742,8 @@ ZEND_API void zend_create_closure(zval *res, zend_function *func, zend_class_ent
if (scope) {
closure->func.common.fn_flags |= ZEND_ACC_PUBLIC;
if (this_ptr && Z_TYPE_P(this_ptr) == IS_OBJECT && (closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0) {
ZVAL_COPY(&closure->this_ptr, this_ptr);
Z_ADDREF_P(this_ptr);
ZVAL_OBJ(&closure->this_ptr, Z_OBJ_P(this_ptr));
}
}
}

View File

@ -1165,7 +1165,8 @@ zend_object_iterator *zend_generator_get_iterator(zend_class_entry *ce, zval *ob
zend_iterator_init(iterator);
iterator->funcs = &zend_generator_iterator_functions;
ZVAL_COPY(&iterator->data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->data, Z_OBJ_P(object));
return iterator;
}

View File

@ -249,7 +249,8 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva
zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->it.data, Z_OBJ_P(object));
iterator->it.funcs = &zend_interface_iterator_funcs_iterator;
iterator->ce = Z_OBJCE_P(object);
ZVAL_UNDEF(&iterator->value);

View File

@ -915,7 +915,8 @@ ZEND_API zval *zend_std_read_dimension(zval *object, zval *offset, int type, zva
ZVAL_COPY_DEREF(&tmp_offset, offset);
}
ZVAL_COPY(&tmp_object, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&tmp_object, Z_OBJ_P(object));
if (type == BP_VAR_IS) {
zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetexists", rv, &tmp_offset);
if (UNEXPECTED(Z_ISUNDEF_P(rv))) {
@ -962,7 +963,8 @@ ZEND_API void zend_std_write_dimension(zval *object, zval *offset, zval *value)
} else {
ZVAL_COPY_DEREF(&tmp_offset, offset);
}
ZVAL_COPY(&tmp_object, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&tmp_object, Z_OBJ_P(object));
zend_call_method_with_2_params(&tmp_object, ce, NULL, "offsetset", NULL, &tmp_offset, value);
zval_ptr_dtor(&tmp_object);
zval_ptr_dtor(&tmp_offset);
@ -980,7 +982,8 @@ ZEND_API int zend_std_has_dimension(zval *object, zval *offset, int check_empty)
if (EXPECTED(instanceof_function_ex(ce, zend_ce_arrayaccess, 1) != 0)) {
ZVAL_COPY_DEREF(&tmp_offset, offset);
ZVAL_COPY(&tmp_object, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&tmp_object, Z_OBJ_P(object));
zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetexists", &retval, &tmp_offset);
result = i_zend_is_true(&retval);
zval_ptr_dtor(&retval);
@ -1136,7 +1139,8 @@ ZEND_API void zend_std_unset_dimension(zval *object, zval *offset) /* {{{ */
if (instanceof_function_ex(ce, zend_ce_arrayaccess, 1)) {
ZVAL_COPY_DEREF(&tmp_offset, offset);
ZVAL_COPY(&tmp_object, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&tmp_object, Z_OBJ_P(object));
zend_call_method_with_1_params(&tmp_object, ce, NULL, "offsetunset", NULL, &tmp_offset);
zval_ptr_dtor(&tmp_object);
zval_ptr_dtor(&tmp_offset);

View File

@ -550,7 +550,8 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec
Z_PTR(I->iter.data) = I;
I->proxy = proxy;
ZVAL_COPY(&I->proxy_obj, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&I->proxy_obj, Z_OBJ_P(object));
I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
for (i = 0; i < proxy->dimensions; i++) {

View File

@ -2009,7 +2009,8 @@ zend_object_iterator *date_object_period_get_iterator(zend_class_entry *ce, zval
zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &date_period_it_funcs;
iterator->object = Z_PHPPERIOD_P(object);
ZVAL_UNDEF(&iterator->current);
@ -3262,7 +3263,7 @@ PHP_FUNCTION(date_modify)
}
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3318,7 +3319,7 @@ PHP_FUNCTION(date_add)
php_date_add(object, interval, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3375,7 +3376,7 @@ PHP_FUNCTION(date_sub)
php_date_sub(object, interval, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3479,7 +3480,7 @@ PHP_FUNCTION(date_timezone_set)
php_date_timezone_set(object, timezone_object, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3565,7 +3566,7 @@ PHP_FUNCTION(date_time_set)
php_date_time_set(object, h, i, s, ms, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3615,7 +3616,7 @@ PHP_FUNCTION(date_date_set)
php_date_date_set(object, y, m, d, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3669,7 +3670,7 @@ PHP_FUNCTION(date_isodate_set)
php_date_isodate_set(object, y, w, d, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */
@ -3718,7 +3719,7 @@ PHP_FUNCTION(date_timestamp_set)
php_date_timestamp_set(object, timestamp, return_value);
Z_ADDREF_P(object);
ZVAL_COPY_VALUE(return_value, object);
ZVAL_OBJ(return_value, Z_OBJ_P(object));
}
/* }}} */

View File

@ -272,7 +272,8 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i
iterator = emalloc(sizeof(php_dom_iterator));
zend_iterator_init(&iterator->intern);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &php_dom_iterator_funcs;
ZVAL_UNDEF(&iterator->curobj);

View File

@ -1815,7 +1815,8 @@ static zend_object_iterator *zend_ffi_cdata_get_iterator(zend_class_entry *ce, z
zend_iterator_init(&iter->it);
ZVAL_COPY(&iter->it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iter->it.data, Z_OBJ_P(object));
iter->it.funcs = &zend_ffi_cdata_it_funcs;
iter->key = 0;
iter->by_ref = by_ref;

View File

@ -605,7 +605,7 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch
/* The "object" variable may be modified during the execution of this unserialize handler
* (it may turn into a reference). Keep the original object around for further operations. */
ZVAL_COPY_VALUE(&object_copy, object);
ZVAL_OBJ(&object_copy, Z_OBJ_P(object));
p = buf;
max = buf + buf_len;

View File

@ -111,7 +111,8 @@ U_CFUNC zend_object_iterator *_breakiterator_get_iterator(
zoi_with_current *zoi_iter = static_cast<zoi_with_current*>(emalloc(sizeof *zoi_iter));
zend_iterator_init(&zoi_iter->zoi);
ZVAL_COPY(&zoi_iter->zoi.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&zoi_iter->zoi.data, Z_OBJ_P(object));
zoi_iter->zoi.funcs = &breakiterator_iterator_funcs;
zoi_iter->zoi.index = 0;
zoi_iter->destroy_it = _breakiterator_destroy_it;
@ -220,7 +221,7 @@ void IntlIterator_from_BreakIterator_parts(zval *break_iter_zv,
ii->iterator->index = 0;
((zoi_with_current*)ii->iterator)->destroy_it = _breakiterator_parts_destroy_it;
ZVAL_COPY_VALUE(&((zoi_with_current*)ii->iterator)->wrapping_obj, object);
ZVAL_OBJ(&((zoi_with_current*)ii->iterator)->wrapping_obj, Z_OBJ_P(object));
ZVAL_UNDEF(&((zoi_with_current*)ii->iterator)->current);
((zoi_break_iter_parts*)ii->iterator)->bio = Z_INTL_BREAKITERATOR_P(break_iter_zv);

View File

@ -323,7 +323,7 @@ static void collator_sort_internal( int renumber, INTERNAL_FUNCTION_PARAMETERS )
/* Save specified collator in the request-global (?) variable. */
ZVAL_COPY_VALUE(&saved_collator, &INTL_G( current_collator ));
ZVAL_COPY_VALUE(&INTL_G( current_collator ), object);
ZVAL_OBJ(&INTL_G( current_collator ), Z_OBJ_P(object));
/* Sort specified array. */
zend_hash_sort(hash, collator_compare_func, renumber);

View File

@ -148,7 +148,7 @@ U_CFUNC void IntlIterator_from_StringEnumeration(StringEnumeration *se, zval *ob
ii->iterator->funcs = &string_enum_object_iterator_funcs;
ii->iterator->index = 0;
((zoi_with_current*)ii->iterator)->destroy_it = string_enum_destroy_it;
ZVAL_COPY_VALUE(&((zoi_with_current*)ii->iterator)->wrapping_obj, object);
ZVAL_OBJ(&((zoi_with_current*)ii->iterator)->wrapping_obj, Z_OBJ_P(object));
ZVAL_UNDEF(&((zoi_with_current*)ii->iterator)->current);
}

View File

@ -157,7 +157,8 @@ zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *o
}
zend_iterator_init(&iterator->intern);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &resourcebundle_iterator_funcs;
iterator->subject = rb;

View File

@ -52,7 +52,8 @@ zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce, zval
iterator = ecalloc(1, sizeof(php_mysqli_result_iterator));
zend_iterator_init(&iterator->intern);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &php_mysqli_result_iterator_funcs;
iterator->result = Z_MYSQLI_P(object);
iterator->row_num = -1;

View File

@ -1108,7 +1108,7 @@ static PHP_METHOD(PDO, query)
}
/* something broke */
dbh->query_stmt = stmt;
ZVAL_COPY_VALUE(&dbh->query_stmt_zval, return_value);
ZVAL_OBJ(&dbh->query_stmt_zval, Z_OBJ_P(return_value));
Z_DELREF(stmt->database_object_handle);
ZVAL_UNDEF(&stmt->database_object_handle);
PDO_HANDLE_STMT_ERR();

View File

@ -2418,7 +2418,8 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object, int
I = ecalloc(1, sizeof(struct php_pdo_iterator));
zend_iterator_init(&I->iter);
I->iter.funcs = &pdo_stmt_iter_funcs;
ZVAL_COPY(&I->iter.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&I->iter.data, Z_OBJ_P(object));
if (!do_fetch(stmt, 1, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT,
PDO_FETCH_ORI_NEXT, 0, 0)) {

View File

@ -1123,7 +1123,7 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
intern->ce = fptr->common.scope;
if (closure_object) {
Z_ADDREF_P(closure_object);
ZVAL_COPY_VALUE(&intern->obj, closure_object);
ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure_object));
}
prop_name = reflection_prop_name(object);
@ -1166,7 +1166,7 @@ static void reflection_function_factory(zend_function *function, zval *closure_o
intern->ce = NULL;
if (closure_object) {
Z_ADDREF_P(closure_object);
ZVAL_COPY_VALUE(&intern->obj, closure_object);
ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure_object));
}
ZVAL_STR_COPY(reflection_prop_name(object), function->common.function_name);
}
@ -1184,7 +1184,7 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho
intern->ce = ce;
if (closure_object) {
Z_ADDREF_P(closure_object);
ZVAL_COPY_VALUE(&intern->obj, closure_object);
ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure_object));
}
ZVAL_STR_COPY(reflection_prop_name(object),
@ -1532,7 +1532,7 @@ ZEND_METHOD(reflection_function, __construct)
intern->ptr = fptr;
intern->ref_type = REF_TYPE_FUNCTION;
if (closure) {
ZVAL_COPY_VALUE(&intern->obj, closure);
ZVAL_OBJ(&intern->obj, Z_OBJ_P(closure));
} else {
ZVAL_UNDEF(&intern->obj);
}
@ -1597,7 +1597,8 @@ ZEND_METHOD(reflection_function, getClosureThis)
if (!Z_ISUNDEF(intern->obj)) {
closure_this = zend_get_closure_this_ptr(&intern->obj);
if (!Z_ISUNDEF_P(closure_this)) {
ZVAL_COPY(return_value, closure_this);
Z_ADDREF_P(closure_this);
ZVAL_OBJ(return_value, Z_OBJ_P(closure_this));
}
}
}
@ -1637,7 +1638,8 @@ ZEND_METHOD(reflection_function, getClosure)
if (!Z_ISUNDEF(intern->obj)) {
/* Closures are immutable objects */
ZVAL_COPY(return_value, &intern->obj);
Z_ADDREF(intern->obj);
ZVAL_OBJ(return_value, Z_OBJ(intern->obj));
} else {
zend_create_fake_closure(return_value, fptr, NULL, NULL, NULL);
}
@ -2066,7 +2068,8 @@ ZEND_METHOD(reflection_generator, __construct)
}
intern->ref_type = REF_TYPE_GENERATOR;
ZVAL_COPY(&intern->obj, generator);
Z_ADDREF_P(generator);
ZVAL_OBJ(&intern->obj, Z_OBJ_P(generator));
intern->ce = zend_ce_generator;
}
/* }}} */
@ -2182,7 +2185,8 @@ ZEND_METHOD(reflection_generator, getThis)
REFLECTION_CHECK_VALID_GENERATOR(ex)
if (Z_TYPE(ex->This) == IS_OBJECT) {
ZVAL_COPY(return_value, &ex->This);
Z_ADDREF(ex->This);
ZVAL_OBJ(return_value, Z_OBJ(ex->This));
} else {
ZVAL_NULL(return_value);
}
@ -3032,7 +3036,8 @@ ZEND_METHOD(reflection_method, getClosure)
if (Z_OBJCE_P(obj) == zend_ce_closure &&
(mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE))
{
ZVAL_COPY(return_value, obj);
Z_ADDREF_P(obj);
ZVAL_OBJ(return_value, Z_OBJ_P(obj));
} else {
zend_create_fake_closure(return_value, mptr, mptr->common.scope, Z_OBJCE_P(obj), obj);
}

View File

@ -356,7 +356,7 @@ long_dim:
}
if (Z_ISUNDEF_P(rv)) {
ZVAL_COPY_VALUE(rv, &EG(uninitialized_zval));
ZVAL_NULL(rv);
}
return rv;
@ -2397,7 +2397,8 @@ zend_object_iterator *php_sxe_get_iterator(zend_class_entry *ce, zval *object, i
iterator = emalloc(sizeof(php_sxe_iterator));
zend_iterator_init(&iterator->intern);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &php_sxe_iterator_funcs;
iterator->sxe = Z_SXEOBJ_P(object);

View File

@ -1321,7 +1321,8 @@ PHP_METHOD(SoapServer, setObject)
service->type = SOAP_OBJECT;
ZVAL_COPY(&service->soap_object, obj);
Z_ADDREF_P(obj);
ZVAL_OBJ(&service->soap_object, Z_OBJ_P(obj));
SOAP_SERVER_END_CODE();
}
@ -2023,7 +2024,8 @@ PHP_METHOD(SoapServer, addSoapHeader)
*p = emalloc(sizeof(soapHeader));
memset(*p, 0, sizeof(soapHeader));
ZVAL_NULL(&(*p)->function_name);
ZVAL_COPY(&(*p)->retval, fault);
Z_ADDREF_P(fault);
ZVAL_OBJ(&(*p)->retval, Z_OBJ_P(fault));
SOAP_SERVER_END_CODE();
}

View File

@ -1163,7 +1163,8 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
zend_iterator_init(&iterator->it);
ZVAL_COPY(&iterator->it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->it.data, Z_OBJ_P(object));
iterator->it.funcs = &spl_array_it_funcs;
iterator->ce = ce;
ZVAL_UNDEF(&iterator->value);

View File

@ -1650,7 +1650,8 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval
}
dir_object = Z_SPLFILESYSTEM_P(object);
iterator = spl_filesystem_object_to_iterator(dir_object);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &spl_filesystem_dir_it_funcs;
/* ->current must be initialized; rewind doesn't set it and valid
* doesn't check whether it's set */
@ -1851,7 +1852,8 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
dir_object = Z_SPLFILESYSTEM_P(object);
iterator = spl_filesystem_object_to_iterator(dir_object);
ZVAL_COPY(&iterator->intern.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &spl_filesystem_tree_it_funcs;
return &iterator->intern;

View File

@ -1360,7 +1360,8 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->intern.it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_dllist_it_funcs;
iterator->intern.ce = ce;
iterator->traverse_position = dllist_object->traverse_position;

View File

@ -1008,7 +1008,8 @@ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *ob
zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->intern.it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_fixedarray_it_funcs;
iterator->intern.ce = ce;
ZVAL_UNDEF(&iterator->intern.value);

View File

@ -1095,7 +1095,8 @@ zend_object_iterator *spl_heap_get_iterator(zend_class_entry *ce, zval *object,
zend_iterator_init(&iterator->intern.it);
ZVAL_COPY(&iterator->intern.it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_heap_it_funcs;
iterator->intern.ce = ce;
iterator->flags = heap_object->flags;
@ -1119,7 +1120,8 @@ zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object
zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->intern.it.data, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_pqueue_it_funcs;
iterator->intern.ce = ce;
iterator->flags = heap_object->flags;

View File

@ -469,7 +469,8 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,
zend_iterator_init((zend_object_iterator*)iterator);
ZVAL_COPY(&iterator->intern.data, zobject);
Z_ADDREF_P(zobject);
ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(zobject));
iterator->intern.funcs = &spl_recursive_it_iterator_funcs;
return (zend_object_iterator*)iterator;
}
@ -582,7 +583,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
ce_iterator = Z_OBJCE_P(iterator); /* respect inheritance, don't use spl_ce_RecursiveIterator */
intern->iterators[0].iterator = ce_iterator->get_iterator(ce_iterator, iterator, 0);
ZVAL_COPY_VALUE(&intern->iterators[0].zobject, iterator);
ZVAL_OBJ(&intern->iterators[0].zobject, Z_OBJ_P(iterator));
intern->iterators[0].ce = ce_iterator;
intern->iterators[0].state = RS_START;
@ -1572,9 +1573,9 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
}
if (inc_refcount) {
Z_TRY_ADDREF_P(zobject);
Z_ADDREF_P(zobject);
}
ZVAL_COPY_VALUE(&intern->inner.zobject, zobject);
ZVAL_OBJ(&intern->inner.zobject, Z_OBJ_P(zobject));
intern->inner.ce = dit_type == DIT_IteratorIterator ? ce : Z_OBJCE_P(zobject);
intern->inner.object = Z_OBJ_P(zobject);

View File

@ -483,7 +483,8 @@ PHP_METHOD(sqlite3, prepare)
object_init_ex(return_value, php_sqlite3_stmt_entry);
stmt_obj = Z_SQLITE3_STMT_P(return_value);
stmt_obj->db_obj = db_obj;
ZVAL_COPY(&stmt_obj->db_obj_zval, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&stmt_obj->db_obj_zval, Z_OBJ_P(object));
errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL);
if (errcode != SQLITE_OK) {
@ -496,7 +497,7 @@ PHP_METHOD(sqlite3, prepare)
free_item = emalloc(sizeof(php_sqlite3_free_list));
free_item->stmt_obj = stmt_obj;
ZVAL_COPY_VALUE(&free_item->stmt_obj_zval, return_value);
ZVAL_OBJ(&free_item->stmt_obj_zval, Z_OBJ_P(return_value));
zend_llist_add_element(&(db_obj->free_list), &free_item);
}
@ -538,7 +539,8 @@ PHP_METHOD(sqlite3, query)
object_init_ex(&stmt, php_sqlite3_stmt_entry);
stmt_obj = Z_SQLITE3_STMT_P(&stmt);
stmt_obj->db_obj = db_obj;
ZVAL_COPY(&stmt_obj->db_obj_zval, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&stmt_obj->db_obj_zval, Z_OBJ_P(object));
return_code = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL);
if (return_code != SQLITE_OK) {
@ -553,7 +555,7 @@ PHP_METHOD(sqlite3, query)
result = Z_SQLITE3_RESULT_P(return_value);
result->db_obj = db_obj;
result->stmt_obj = stmt_obj;
ZVAL_COPY_VALUE(&result->stmt_obj_zval, &stmt);
ZVAL_OBJ(&result->stmt_obj_zval, Z_OBJ(stmt));
return_code = sqlite3_step(result->stmt_obj->stmt);
@ -1733,7 +1735,8 @@ PHP_METHOD(sqlite3stmt, execute)
result->is_prepared_statement = 1;
result->db_obj = stmt_obj->db_obj;
result->stmt_obj = stmt_obj;
ZVAL_COPY(&result->stmt_obj_zval, object);
Z_ADDREF_P(object);
ZVAL_OBJ(&result->stmt_obj_zval, Z_OBJ_P(object));
break;
}
@ -1782,7 +1785,8 @@ PHP_METHOD(sqlite3stmt, __construct)
}
stmt_obj->db_obj = db_obj;
ZVAL_COPY(&stmt_obj->db_obj_zval, db_zval);
Z_ADDREF_P(db_zval);
ZVAL_OBJ(&stmt_obj->db_obj_zval, Z_OBJ_P(db_zval));
errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL);
if (errcode != SQLITE_OK) {
@ -1795,7 +1799,7 @@ PHP_METHOD(sqlite3stmt, __construct)
free_item = emalloc(sizeof(php_sqlite3_free_list));
free_item->stmt_obj = stmt_obj;
//?? free_item->stmt_obj_zval = ZEND_THIS;
ZVAL_COPY_VALUE(&free_item->stmt_obj_zval, object);
ZVAL_OBJ(&free_item->stmt_obj_zval, Z_OBJ_P(object));
zend_llist_add_element(&(db_obj->free_list), &free_item);
}

View File

@ -368,7 +368,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername,
/* set the filter property, this will be used during cleanup */
ZVAL_RES(&zfilter, zend_register_resource(filter, le_userfilters));
ZVAL_COPY_VALUE(&filter->abstract, &obj);
ZVAL_OBJ(&filter->abstract, Z_OBJ(obj));
add_property_zval(&obj, "filter", &zfilter);
/* add_property_zval increments the refcount which is unwanted here */
zval_ptr_dtor(&zfilter);

View File

@ -947,7 +947,8 @@ again:
zval *data;
zend_ulong index;
ZVAL_COPY(&obj, struc);
Z_ADDREF_P(struc);
ZVAL_OBJ(&obj, Z_OBJ_P(struc));
if (php_var_serialize_call_magic_serialize(&retval, &obj) == FAILURE) {
if (!EG(exception)) {
smart_str_appendl(buf, "N;", 2);
@ -1009,7 +1010,9 @@ again:
if (ce != PHP_IC_ENTRY && zend_hash_str_exists(&ce->function_table, "__sleep", sizeof("__sleep")-1)) {
zval retval, tmp;
ZVAL_COPY(&tmp, struc);
Z_ADDREF_P(struc);
ZVAL_OBJ(&tmp, Z_OBJ_P(struc));
if (php_var_serialize_call_sleep(&retval, &tmp) == FAILURE) {
if (!EG(exception)) {

View File

@ -1200,7 +1200,8 @@ PHP_FUNCTION(xml_set_object)
/* please leave this commented - or ask thies@thieso.net before doing it (again) */
/* zval_add_ref(&parser->object); */
ZVAL_COPY(&parser->object, mythis);
Z_ADDREF_P(mythis);
ZVAL_OBJ(&parser->object, Z_OBJ_P(mythis));
RETVAL_TRUE;
}