mirror of
https://github.com/php/php-src.git
synced 2026-04-19 22:11:12 +02:00
Merge branch 'refactoring2' of github.com:zendtech/php into refactoring2
This commit is contained in:
23
Zend/zend.h
23
Zend/zend.h
@@ -680,15 +680,20 @@ END_EXTERN_C()
|
||||
Z_UNSET_ISREF_P(z); \
|
||||
} while (0)
|
||||
|
||||
// TODO: support objects and resources???
|
||||
#define SEPARATE_ZVAL(zv) do { \
|
||||
if (Z_REFCOUNTED_P(zv)) { \
|
||||
if (Z_REFCOUNT_P(zv) > 1) { \
|
||||
Z_DELREF_P(zv); \
|
||||
zval_copy_ctor(zv); \
|
||||
Z_SET_REFCOUNT_P(zv, 1); \
|
||||
} \
|
||||
} \
|
||||
// TODO: support objects and resources in more optimal way ???
|
||||
#define SEPARATE_ZVAL(zv) do { \
|
||||
if (Z_REFCOUNTED_P(zv)) { \
|
||||
if (Z_REFCOUNT_P(zv) > 1) { \
|
||||
if (Z_TYPE_P(zv) == IS_OBJECT || \
|
||||
Z_TYPE_P(zv) == IS_RESOURCE) { \
|
||||
Z_ADDREF_P(zv); \
|
||||
} else { \
|
||||
Z_DELREF_P(zv); \
|
||||
zval_copy_ctor(zv); \
|
||||
Z_SET_REFCOUNT_P(zv, 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SEPARATE_ZVAL_IF_NOT_REF(zv) \
|
||||
|
||||
@@ -3076,7 +3076,7 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */
|
||||
|
||||
ALLOC_HASHTABLE(op_array->static_variables);
|
||||
zend_hash_init(op_array->static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(op_array->static_variables, static_variables, zval_add_ref);
|
||||
zend_hash_copy(op_array->static_variables, static_variables, zval_add_ref_unref);
|
||||
}
|
||||
op_array->run_time_cache = NULL;
|
||||
}
|
||||
|
||||
@@ -830,7 +830,7 @@ static inline void zend_assign_to_object(zval *retval, zval *object_ptr, zval *p
|
||||
Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC);
|
||||
}
|
||||
|
||||
if (retval && EG(exception) != NULL) {
|
||||
if (retval && !EG(exception)) {
|
||||
ZVAL_COPY(retval, value);
|
||||
}
|
||||
zval_ptr_dtor(value);
|
||||
|
||||
@@ -150,7 +150,7 @@ ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *o
|
||||
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, zval_add_ref);
|
||||
zend_hash_copy(new_object->properties, old_object->properties, zval_add_ref_unref);
|
||||
if (old_object->properties_table) {
|
||||
HashPosition pos;
|
||||
zval *prop;
|
||||
|
||||
@@ -187,11 +187,26 @@ ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC)
|
||||
|
||||
ZEND_API void zval_add_ref(zval *p)
|
||||
{
|
||||
if (Z_REFCOUNTED_P(p)) {
|
||||
if (Z_REFCOUNTED_P(p)) {
|
||||
Z_ADDREF_P(p);
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API void zval_add_ref_unref(zval *p)
|
||||
{
|
||||
if (Z_REFCOUNTED_P(p)) {
|
||||
if (Z_ISREF_P(p)) {
|
||||
if (Z_REFCOUNT_P(p) == 1) {
|
||||
zval *q = Z_REFVAL_P(p);
|
||||
ZVAL_DUP(p, q);
|
||||
} else {
|
||||
Z_ADDREF_P(p);
|
||||
}
|
||||
} else {
|
||||
Z_ADDREF_P(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
|
||||
{
|
||||
|
||||
@@ -78,6 +78,8 @@ ZEND_API void _zval_internal_ptr_dtor_wrapper(zval *zvalue);
|
||||
#endif
|
||||
|
||||
ZEND_API void zval_add_ref(zval *p);
|
||||
//??? previously references become regular values when refcount became 1
|
||||
ZEND_API void zval_add_ref_unref(zval *p);
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user