diff options
86 files changed, 983 insertions, 918 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index 76651bc5b1..c299f12757 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -325,7 +325,7 @@ ZEND_API void zend_make_string_zval(zval *expr, zval *expr_copy, int *use_copy)  				if (Z_OBJ_HANDLER_P(expr, get)) {  					zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); -					z->refcount++; +					Z_ADDREF_P(z);  					if(Z_TYPE_P(z) != IS_OBJECT) {  						zend_make_string_zval(z, expr_copy, use_copy);  						if (*use_copy) { @@ -395,7 +395,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop  			if (Z_OBJ_HANDLER_P(expr, get)) {  				zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); -				z->refcount++; +				Z_ADDREF_P(z);  				if(Z_TYPE_P(z) != IS_OBJECT) {  					zend_make_printable_zval(z, expr_copy, use_copy);  					if (*use_copy) { @@ -447,7 +447,7 @@ ZEND_API void zend_make_unicode_zval(zval *expr, zval *expr_copy, int *use_copy)  			if (Z_OBJ_HANDLER_P(expr, get)) {  				zval *z = Z_OBJ_HANDLER_P(expr, get)(expr TSRMLS_CC); -				z->refcount++; +				Z_ADDREF_P(z);  				if(Z_TYPE_P(z) != IS_OBJECT) {  					zend_make_unicode_zval(z, expr_copy, use_copy);  					if (*use_copy) { @@ -1081,8 +1081,8 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i  	/* This zval can be used to initialize allocate zval's to an uninit'ed value */ -	zval_used_for_init.is_ref = 0; -	zval_used_for_init.refcount = 1; +	zval_used_for_init.is_ref__gc = 0; +	zval_used_for_init.refcount__gc = 1;  	Z_TYPE(zval_used_for_init) = IS_NULL;  #ifdef ZTS diff --git a/Zend/zend.h b/Zend/zend.h index 8fb4a2d41f..8f922e1572 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -333,12 +333,80 @@ typedef union _zvalue_value {  struct _zval_struct {  	/* Variable information */  	zvalue_value value;		/* value */ -	zend_uint refcount; +	zend_uint refcount__gc;  	zend_uchar type;	/* active type */ -	zend_uchar is_ref; +	zend_uchar is_ref__gc;  	zend_uchar idx_type;	/* type of element's index in constant array */  }; +#define Z_REFCOUNT_PP(ppz)		Z_REFCOUNT_P(*(ppz)) +#define Z_SET_REFCOUNT_PP(ppz, rc)	Z_SET_REFCOUNT_P(*(ppz), rc) +#define Z_ADDREF_PP(ppz)		Z_ADDREF_P(*(ppz)) +#define Z_DELREF_PP(ppz)		Z_DELREF_P(*(ppz)) +#define Z_ISREF_PP(ppz)			Z_ISREF_P(*(ppz)) +#define Z_SET_ISREF_PP(ppz)		Z_SET_ISREF_P(*(ppz)) +#define Z_UNSET_ISREF_PP(ppz)		Z_UNSET_ISREF_P(*(ppz)) +#define Z_SET_ISREF_TO_PP(ppz, isref)	Z_SET_ISREF_TO_P(*(ppz), isref) + +#define Z_REFCOUNT_P(pz)		zval_refcount_p(pz) +#define Z_SET_REFCOUNT_P(pz, rc)	zval_set_refcount_p(pz, rc) +#define Z_ADDREF_P(pz)			zval_addref_p(pz) +#define Z_DELREF_P(pz)			zval_delref_p(pz) +#define Z_ISREF_P(pz)			zval_isref_p(pz) +#define Z_SET_ISREF_P(pz)		zval_set_isref_p(pz) +#define Z_UNSET_ISREF_P(pz)		zval_unset_isref_p(pz) +#define Z_SET_ISREF_TO_P(pz, isref)	zval_set_isref_to_p(pz, isref) + +#define Z_REFCOUNT(z)			Z_REFCOUNT_P(&(z)) +#define Z_SET_REFCOUNT(z, rc)		Z_SET_REFCOUNT_P(&(z), rc) +#define Z_ADDREF(z)			Z_ADDREF_P(&(z)) +#define Z_DELREF(z)			Z_DELREF_P(&(z)) +#define Z_ISREF(z)			Z_ISREF_P(&(z)) +#define Z_SET_ISREF(z)			Z_SET_ISREF_P(&(z)) +#define Z_UNSET_ISREF(z)		Z_UNSET_ISREF_P(&(z)) +#define Z_SET_ISREF_TO(z, isref)	Z_SET_ISREF_TO_P(&(z), isref) + +#if defined(__GNUC__) +#define always_inline inline __attribute__((always_inline)) +#elif defined(_MSC_VER) +#define always_inline __forceinline +#else +#define always_inline inline +#endif + +static always_inline zend_uint zval_refcount_p(zval* pz) { +	return pz->refcount__gc; +} + +static always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) { +	return pz->refcount__gc = rc; +} + +static always_inline zend_uint zval_addref_p(zval* pz) { +	return ++pz->refcount__gc; +} + +static always_inline zend_uint zval_delref_p(zval* pz) { +	return --pz->refcount__gc; +} + +static always_inline zend_bool zval_isref_p(zval* pz) { +	return pz->is_ref__gc; +} + +static always_inline zend_bool zval_set_isref_p(zval* pz) { +	return pz->is_ref__gc = 1; +} + +static always_inline zend_bool zval_unset_isref_p(zval* pz) { +	return pz->is_ref__gc = 0; +} + +static always_inline zend_bool zval_set_isref_to_p(zval* pz, zend_bool isref) { + +	return pz->is_ref__gc = isref; +} +  /* excpt.h on Digital Unix 4.0 defines function_table */  #undef function_table @@ -611,13 +679,9 @@ END_EXTERN_C()  #define ZMSG_MEMORY_LEAKS_GRAND_TOTAL	7L -#define ZVAL_ADDREF(pz)		(++(pz)->refcount) -#define ZVAL_DELREF(pz)		(--(pz)->refcount) -#define ZVAL_REFCOUNT(pz)	((pz)->refcount) -  #define INIT_PZVAL(z)		\ -	(z)->refcount = 1;		\ -	(z)->is_ref = 0; +	(z)->refcount__gc = 1;	\ +	(z)->is_ref__gc = 0;  #define INIT_ZVAL(z) z = zval_used_for_init; @@ -629,19 +693,19 @@ END_EXTERN_C()  	ALLOC_ZVAL(zv); \  	INIT_PZVAL(zv); -#define PZVAL_IS_REF(z)		((z)->is_ref) +#define PZVAL_IS_REF(z)		Z_ISREF_P(z)  #define SEPARATE_ZVAL(ppzv)									\  	{														\  		zval *orig_ptr = *(ppzv);							\  															\ -		if (orig_ptr->refcount>1) {							\ -			orig_ptr->refcount--;							\ +		if (Z_REFCOUNT_P(orig_ptr) > 1) {							\ +			Z_DELREF_P(orig_ptr);							\  			ALLOC_ZVAL(*(ppzv));							\  			**(ppzv) = *orig_ptr;							\  			zval_copy_ctor(*(ppzv));						\ -			(*(ppzv))->refcount=1;							\ -			(*(ppzv))->is_ref = 0;							\ +			Z_SET_REFCOUNT_PP(ppzv, 1);							\ +			Z_UNSET_ISREF_PP((ppzv));							\  		}													\  	} @@ -653,14 +717,14 @@ END_EXTERN_C()  #define SEPARATE_ZVAL_TO_MAKE_IS_REF(ppzv)	\  	if (!PZVAL_IS_REF(*ppzv)) {				\  		SEPARATE_ZVAL(ppzv);				\ -		(*(ppzv))->is_ref = 1;				\ +		Z_SET_ISREF_PP((ppzv));				\  	}  #define COPY_PZVAL_TO_ZVAL(zv, pzv)			\  	(zv) = *(pzv);							\ -	if ((pzv)->refcount>1) {				\ +	if (Z_REFCOUNT_P(pzv)>1) {				\  		zval_copy_ctor(&(zv));				\ -		(pzv)->refcount--;					\ +		Z_DELREF_P((pzv));					\  	} else {								\  		FREE_ZVAL(pzv);						\  	}										\ @@ -670,15 +734,15 @@ END_EXTERN_C()  	int is_ref, refcount;						\  												\  	SEPARATE_ZVAL_IF_NOT_REF(ppzv_dest);		\ -	is_ref = (*ppzv_dest)->is_ref;				\ -	refcount = (*ppzv_dest)->refcount;			\ +	is_ref = Z_ISREF_PP(ppzv_dest);				\ +	refcount = Z_REFCOUNT_PP(ppzv_dest);			\  	zval_dtor(*ppzv_dest);						\  	**ppzv_dest = *pzv_src;						\  	if (copy) {                                 \  		zval_copy_ctor(*ppzv_dest);				\      }		                                    \ -	(*ppzv_dest)->is_ref = is_ref;				\ -	(*ppzv_dest)->refcount = refcount;			\ +	Z_SET_ISREF_TO_PP(ppzv_dest, is_ref);				\ +	Z_SET_REFCOUNT_PP(ppzv_dest, refcount);			\  }  #define SEPARATE_ARG_IF_REF(varptr) \ @@ -687,15 +751,15 @@ END_EXTERN_C()  		ALLOC_ZVAL(varptr); \  		varptr->value = original_var->value; \  		Z_TYPE_P(varptr) = Z_TYPE_P(original_var); \ -		varptr->is_ref = 0; \ -		varptr->refcount = 1; \ +		Z_UNSET_ISREF_P(varptr); \ +		Z_SET_REFCOUNT_P(varptr, 1); \  		zval_copy_ctor(varptr); \  	} else { \ -		varptr->refcount++; \ +		Z_ADDREF_P(varptr); \  	}  #define READY_TO_DESTROY(zv) \ -	((zv)->refcount == 1 && \ +	(Z_REFCOUNT_P(zv) == 1 && \  	 (Z_TYPE_P(zv) != IS_OBJECT || \  	  zend_objects_store_get_refcount(zv TSRMLS_CC) == 1)) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index b5d8e5310d..719b6a8828 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -55,7 +55,7 @@ ZEND_API int zend_get_parameters(int ht, int param_count, ...) /* {{{ */  	while (param_count-->0) {  		param = va_arg(ptr, zval **);  		param_ptr = *(p-arg_count); -		if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) { +		if (!PZVAL_IS_REF(param_ptr) && Z_REFCOUNT_P(param_ptr) > 1) {  			zval *new_tmp;  			ALLOC_ZVAL(new_tmp); @@ -63,7 +63,7 @@ ZEND_API int zend_get_parameters(int ht, int param_count, ...) /* {{{ */  			zval_copy_ctor(new_tmp);  			INIT_PZVAL(new_tmp);  			param_ptr = new_tmp; -			((zval *) *(p-arg_count))->refcount--; +			Z_DELREF_P((zval *) *(p-arg_count));  			*(p-arg_count) = param_ptr;  		}  		*param = param_ptr; @@ -90,7 +90,7 @@ ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument  	while (param_count-->0) {  		param_ptr = *(p-arg_count); -		if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) { +		if (!PZVAL_IS_REF(param_ptr) && Z_REFCOUNT_P(param_ptr) > 1) {  			zval *new_tmp;  			ALLOC_ZVAL(new_tmp); @@ -98,7 +98,7 @@ ZEND_API int _zend_get_parameters_array(int ht, int param_count, zval **argument  			zval_copy_ctor(new_tmp);  			INIT_PZVAL(new_tmp);  			param_ptr = new_tmp; -			((zval *) *(p-arg_count))->refcount--; +			Z_DELREF_P((zval *) *(p-arg_count));  			*(p-arg_count) = param_ptr;  		}  		*(argument_array++) = param_ptr; @@ -291,7 +291,7 @@ static int parse_arg_object_to_string(zval **arg, char **p, int *pl, int type TS  	if (!Z_OBJ_HANDLER_PP(arg, cast_object) && Z_OBJ_HANDLER_PP(arg, get)) {  		int use_copy;  		zval *z = Z_OBJ_HANDLER_PP(arg, get)(*arg TSRMLS_CC); -		z->refcount++; +		Z_ADDREF_P(z);  		if(Z_TYPE_P(z) != IS_OBJECT) {  			zval_dtor(*arg);  			Z_TYPE_P(*arg) = IS_NULL; @@ -1269,13 +1269,13 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC  						utype = IS_STRING;  						break;  				} -				if ((*p)->is_ref && +				if (Z_ISREF_PP(p) &&  				    class_type->parent &&  				    zend_u_hash_find(&class_type->parent->default_static_members, utype, str_index, str_length, (void**)&q) == SUCCESS &&  				    *p == *q &&  				    zend_u_hash_find(CE_STATIC_MEMBERS(class_type->parent), utype, str_index, str_length, (void**)&q) == SUCCESS) { -					(*q)->refcount++; -					(*q)->is_ref = 1; +					Z_ADDREF_PP(q); +					Z_SET_ISREF_PP(q);  					zend_u_hash_add(CE_STATIC_MEMBERS(class_type), utype, str_index, str_length, (void**)q, sizeof(zval*), NULL);  				} else {  					zval *q; @@ -2548,7 +2548,7 @@ ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length, zen  	if (num_symbol_tables <= 0) return FAILURE; -	symbol->is_ref = is_ref; +	Z_SET_ISREF_TO_P(symbol, is_ref);  	va_start(symbol_table_list, num_symbol_tables);  	while (num_symbol_tables-- > 0) { @@ -3069,7 +3069,7 @@ ZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args TSRMLS_DC) /*  	zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);  	while (zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void *) &arg, &pos) == SUCCESS) {  		*params++ = arg; -		ZVAL_ADDREF(*arg); +		Z_ADDREF_P(*arg);  		zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos);  	} @@ -3092,7 +3092,7 @@ ZEND_API int zend_fcall_info_argp(zend_fcall_info *fci TSRMLS_DC, int argc, zval  		fci->params = (zval ***) erealloc(fci->params, fci->param_count * sizeof(zval **));  		for (i = 0; i < argc; ++i) { -			ZVAL_ADDREF(*(argv[i])); +			Z_ADDREF_P(*(argv[i]));  			fci->params[i] = argv[i];  		}  	} @@ -3118,7 +3118,7 @@ ZEND_API int zend_fcall_info_argv(zend_fcall_info *fci TSRMLS_DC, int argc, va_l  		for (i = 0; i < argc; ++i) {  			arg = va_arg(*argv, zval **); -			ZVAL_ADDREF(*arg); +			Z_ADDREF_P(*arg);  			fci->params[i] = arg;  		}  	} @@ -3525,8 +3525,8 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_NULL(tmp);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3537,8 +3537,8 @@ ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, c  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_BOOL(tmp, value);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3549,8 +3549,8 @@ ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, c  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_LONG(tmp, value);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3561,8 +3561,8 @@ ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object,  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_DOUBLE(tmp, value);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3573,8 +3573,8 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object,  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_STRING(tmp, value, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3585,8 +3585,8 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_STRINGL(tmp, value, value_len, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3597,8 +3597,8 @@ ZEND_API void zend_update_property_ascii_string(zend_class_entry *scope, zval *o  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_ASCII_STRING(tmp, value, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3609,8 +3609,8 @@ ZEND_API void zend_update_property_ascii_stringl(zend_class_entry *scope, zval *  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_ASCII_STRINGL(tmp, value, value_len, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3621,8 +3621,8 @@ ZEND_API void zend_update_property_rt_string(zend_class_entry *scope, zval *obje  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_RT_STRING(tmp, value, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3633,8 +3633,8 @@ ZEND_API void zend_update_property_rt_stringl(zend_class_entry *scope, zval *obj  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_RT_STRINGL(tmp, value, value_len, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3645,8 +3645,8 @@ ZEND_API void zend_update_property_unicode(zend_class_entry *scope, zval *object  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_UNICODE(tmp, value, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3657,8 +3657,8 @@ ZEND_API void zend_update_property_unicodel(zend_class_entry *scope, zval *objec  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_UNICODEL(tmp, value, value_len, 1);  	zend_update_property(scope, object, name, name_length, tmp TSRMLS_CC);  } @@ -3680,13 +3680,13 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, in  				zval_dtor(*property);  				Z_TYPE_PP(property) = Z_TYPE_P(value);  				(*property)->value = value->value; -				if (value->refcount > 0) { +				if (Z_REFCOUNT_P(value) > 0) {  					zval_copy_ctor(*property);  				}  			} else {  				zval *garbage = *property; -				value->refcount++; +				Z_ADDREF_P(value);  				if (PZVAL_IS_REF(value)) {  					SEPARATE_ZVAL(&value);  				} @@ -3704,8 +3704,8 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, char *nam  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_NULL(tmp);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3716,8 +3716,8 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, char *nam  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_BOOL(tmp, value);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3728,8 +3728,8 @@ ZEND_API int zend_update_static_property_long(zend_class_entry *scope, char *nam  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_LONG(tmp, value);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3740,8 +3740,8 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, char *n  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_DOUBLE(tmp, value);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3752,8 +3752,8 @@ ZEND_API int zend_update_static_property_string(zend_class_entry *scope, char *n  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_STRING(tmp, value, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3764,8 +3764,8 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, char *  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_STRINGL(tmp, value, value_len, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3776,8 +3776,8 @@ ZEND_API int zend_update_static_property_ascii_string(zend_class_entry *scope, c  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_ASCII_STRING(tmp, value, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3788,8 +3788,8 @@ ZEND_API int zend_update_static_property_ascii_stringl(zend_class_entry *scope,  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_ASCII_STRINGL(tmp, value, value_len, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3800,8 +3800,8 @@ ZEND_API int zend_update_static_property_rt_string(zend_class_entry *scope, char  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_RT_STRING(tmp, value, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3812,8 +3812,8 @@ ZEND_API int zend_update_static_property_rt_stringl(zend_class_entry *scope, cha  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_RT_STRINGL(tmp, value, value_len, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3824,8 +3824,8 @@ ZEND_API int zend_update_static_property_unicode(zend_class_entry *scope, char *  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_UNICODE(tmp, value, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } @@ -3836,8 +3836,8 @@ ZEND_API int zend_update_static_property_unicodel(zend_class_entry *scope, char  	zval *tmp;  	ALLOC_ZVAL(tmp); -	tmp->is_ref = 0; -	tmp->refcount = 0; +	Z_UNSET_ISREF_P(tmp); +	Z_SET_REFCOUNT_P(tmp, 0);  	ZVAL_UNICODEL(tmp, value, value_len, 1);  	return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC);  } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index c6a591f988..1e4c86c4c8 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1793,8 +1793,8 @@ END_EXTERN_C()  #define ZVAL_ZVAL(z, zv, copy, dtor) {  \  		int is_ref, refcount;           \ -		is_ref = (z)->is_ref;           \ -		refcount = (z)->refcount;       \ +		is_ref = Z_ISREF_P(z);           \ +		refcount = Z_REFCOUNT_P(z);       \  		*(z) = *(zv);                   \  		if (copy) {                     \  			zval_copy_ctor(z);          \ @@ -1805,8 +1805,8 @@ END_EXTERN_C()  			}                           \  			zval_ptr_dtor(&zv);         \  	    }                               \ -		(z)->is_ref = is_ref;           \ -		(z)->refcount = refcount;       \ +		Z_SET_ISREF_TO_P(z, is_ref);           \ +		Z_SET_REFCOUNT_P(z, refcount);       \  	}  #define ZVAL_TEXT(z, t, duplicate)					\ @@ -1998,19 +1998,19 @@ END_EXTERN_C()  																										\  		if (zend_u_hash_find(symtable, (type), (name), (name_length), (void **) &orig_var)==SUCCESS				\  			&& PZVAL_IS_REF(*orig_var)) {																\ -			(var)->refcount = (*orig_var)->refcount;													\ -			(var)->is_ref = 1;																			\ +			Z_SET_REFCOUNT_P(var, Z_REFCOUNT_PP(orig_var));													\ +			Z_SET_ISREF_P(var);																			\  																										\  			if (_refcount) {																			\ -				(var)->refcount += _refcount-1;															\ +				Z_SET_REFCOUNT_P(var, Z_REFCOUNT_P(var) + _refcount - 1);															\  			}																							\  			zval_dtor(*orig_var);																		\  			**orig_var = *(var);																		\  			FREE_ZVAL(var);																					\  		} else {																						\ -			(var)->is_ref = _is_ref;																	\ +			Z_SET_ISREF_TO_P(var, _is_ref);																	\  			if (_refcount) {																			\ -				(var)->refcount = _refcount;															\ +				Z_SET_REFCOUNT_P(var, _refcount);															\  			}																							\  			zend_u_hash_update(symtable, (type), (name), (name_length), &(var), sizeof(zval *), NULL);			\  		}																								\ @@ -2022,19 +2022,19 @@ END_EXTERN_C()  																										\  		if (zend_rt_hash_find(symtable, (name), (name_length), (void **) &orig_var)==SUCCESS				\  			&& PZVAL_IS_REF(*orig_var)) {																\ -			(var)->refcount = (*orig_var)->refcount;													\ -			(var)->is_ref = 1;																			\ +			Z_SET_REFCOUNT_P(var, Z_REFCOUNT_PP(orig_var));													\ +			Z_SET_ISREF_P(var);																			\  																										\  			if (_refcount) {																			\ -				(var)->refcount += _refcount-1;															\ +				Z_SET_REFCOUNT_P(var, Z_REFCOUNT_P(var) + _refcount - 1);															\  			}																							\  			zval_dtor(*orig_var);																		\  			**orig_var = *(var);																		\  			FREE_ZVAL(var);																					\  		} else {																						\ -			(var)->is_ref = _is_ref;																	\ +			Z_SET_ISREF_TO_P(var, _is_ref);																	\  			if (_refcount) {																			\ -				(var)->refcount = _refcount;															\ +				Z_SET_REFCOUNT_P(var, _refcount);															\  			}																							\  			zend_rt_hash_update(symtable, (name), (name_length), &(var), sizeof(zval *), NULL);			\  		}																								\ diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 51cbc34f38..74a017097b 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -419,18 +419,18 @@ ZEND_FUNCTION(each)  	entry = *entry_ptr;  	/* add value elements */ -	if (entry->is_ref) { +	if (Z_ISREF_P(entry)) {  		ALLOC_ZVAL(tmp);  		*tmp = *entry;  		zval_copy_ctor(tmp); -		tmp->is_ref=0; -		tmp->refcount=0; +		Z_UNSET_ISREF_P(tmp); +		Z_SET_REFCOUNT_P(tmp, 0);  		entry=tmp;  	}  	zend_hash_index_update(Z_ARRVAL_P(return_value), 1, &entry, sizeof(zval *), NULL); -	entry->refcount++; +	Z_ADDREF_P(entry);  	zend_ascii_hash_update(Z_ARRVAL_P(return_value), "value", sizeof("value"), &entry, sizeof(zval *), NULL); -	entry->refcount++; +	Z_ADDREF_P(entry);  	/* add the key elements */  	switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 1, NULL)) { @@ -445,7 +445,7 @@ ZEND_FUNCTION(each)  			break;  	}  	zend_ascii_hash_update(Z_ARRVAL_P(return_value), "key", sizeof("key"), inserted_pointer, sizeof(zval *), NULL); -	(*inserted_pointer)->refcount++; +	Z_ADDREF_PP(inserted_pointer);  	zend_hash_move_forward(target_hash);  }  /* }}} */ @@ -868,7 +868,7 @@ ZEND_FUNCTION(get_object_vars)  			if (zend_check_property_access(zobj, ZEND_STR_TYPE, key, key_len-1 TSRMLS_CC) == SUCCESS) {  				zend_u_unmangle_property_name(ZEND_STR_TYPE, key, key_len-1, &class_name, &prop_name);  				/* Not separating references */ -				(*value)->refcount++; +				Z_ADDREF_PP(value);  				add_u_assoc_zval(return_value, ZEND_STR_TYPE, prop_name, *value);  			}  		} @@ -1796,7 +1796,7 @@ static zval *debug_backtrace_get_args(void ***curpos TSRMLS_DC) /* {{{ */  			if (Z_TYPE_PP(arg) != IS_OBJECT) {  				SEPARATE_ZVAL_TO_MAKE_IS_REF(arg);  			} -			(*arg)->refcount++; +			Z_ADDREF_PP(arg);  			add_next_index_zval(arg_array, *arg);  		} else {  			add_next_index_null(arg_array); @@ -2146,7 +2146,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int  				}  				if (provide_object) {  					add_ascii_assoc_zval_ex(stack_frame, "object", sizeof("object"), ptr->object); -					ptr->object->refcount++; +					Z_ADDREF_P(ptr->object);  				}  				add_ascii_assoc_ascii_string_ex(stack_frame, "type", sizeof("type"), "->", 1); diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a99c7d218a..8e0b331b73 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -116,7 +116,7 @@ static void build_runtime_defined_function_key(zval *result, zend_uchar type, zs  		memcpy(Z_STRVAL_P(result)+1+name_length+filename_length, char_pos_buf, char_pos_len+1);  		Z_TYPE_P(result) = IS_STRING;  	} -	result->refcount = 1; +	Z_SET_REFCOUNT_P(result, 1);  }  /* }}} */ @@ -1265,7 +1265,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n  		Z_TYPE(opline->op2.u.constant) = Z_TYPE(function_name->u.constant);  		Z_UNIVAL(opline->op2.u.constant) = lcname;  		Z_UNILEN(opline->op2.u.constant) = lcname_len; -		opline->op2.u.constant.refcount = 1; +		Z_SET_REFCOUNT(opline->op2.u.constant, 1);  		opline->extended_value = ZEND_DECLARE_FUNCTION;  		zend_u_hash_update(CG(function_table), Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array));  	} @@ -2514,7 +2514,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro  				zval **pvalue;  				if (zend_u_hash_quick_find(&parent_ce->default_properties, utype, parent_info->name, parent_info->name_length+1, parent_info->h, (void **) &pvalue) == SUCCESS) { -					(*pvalue)->refcount++; +					Z_ADDREF_PP(pvalue);  					zend_u_hash_del(&ce->default_properties, utype, child_info->name, child_info->name_length+1);  					zend_u_hash_quick_update(&ce->default_properties, utype, parent_info->name, parent_info->name_length+1, parent_info->h, pvalue, sizeof(zval *), NULL);  				} @@ -2546,7 +2546,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro  								parent_ce->name, prop_name, ce->name);  						}  					} -					(*prop)->refcount++; +					Z_ADDREF_PP(prop);  					zend_u_hash_update(&ce->default_static_members, utype, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL);  					zend_u_hash_del(&ce->default_static_members, utype, prot_name, prot_name_length+1);  				} @@ -2617,7 +2617,7 @@ static int inherit_static_prop(zval **p, int num_args, va_list args, zend_hash_k  	if (!zend_u_hash_quick_exists(target, key->type, key->arKey, key->nKeyLength, key->h)) {  		SEPARATE_ZVAL_TO_MAKE_IS_REF(p);  		if (zend_u_hash_quick_add(target, key->type, key->arKey, key->nKeyLength, key->h, p, sizeof(zval*), NULL) == SUCCESS) { -			(*p)->refcount++; +			Z_ADDREF_PP(p);  		}  	}  	return ZEND_HASH_APPLY_KEEP; @@ -3239,7 +3239,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod  	opline->op2.op_type = IS_CONST;  	Z_TYPE(opline->op2.u.constant) = Z_TYPE(class_name->u.constant); -	opline->op2.u.constant.refcount = 1; +	Z_SET_REFCOUNT(opline->op2.u.constant, 1);  	if (doing_inheritance) {  		opline->extended_value = parent_class_name->u.var; diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 728bbf237f..b09c7f82a3 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -301,8 +301,8 @@ ZEND_API int zend_u_get_constant(zend_uchar type, zstr name, uint name_len, zval  	if (retval) {  		*result = c->value;  		zval_copy_ctor(result); -		result->refcount = 1; -		result->is_ref = 0; +		Z_SET_REFCOUNT_P(result, 1); +		Z_UNSET_ISREF_P(result);  	}  	return retval; @@ -428,8 +428,8 @@ ZEND_API int zend_u_get_constant_ex(zend_uchar type, zstr name, uint name_len, z  				*result = c->value;  				zval_update_constant_ex(&result, (void*)1, NULL TSRMLS_CC);  				zval_copy_ctor(result); -				result->refcount = 1; -				result->is_ref = 0; +				Z_SET_REFCOUNT_P(result, 1); +				Z_UNSET_ISREF_P(result);  				return 1;  			}  			efree(lcname.v); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 64604520c6..63acc94cdf 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -88,8 +88,8 @@ static zend_object_value zend_default_exception_new_ex(zend_class_entry *class_t  	zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));  	ALLOC_ZVAL(trace); -	trace->is_ref = 0; -	trace->refcount = 0; +	Z_UNSET_ISREF_P(trace); +	Z_SET_REFCOUNT_P(trace, 0);  	zend_fetch_debug_backtrace(trace, skip_top_traces, 0 TSRMLS_CC);  	zend_update_property_rt_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 4df2fe9d36..0dc39395ff 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -67,15 +67,15 @@ static void zend_extension_fcall_end_handler(zend_extension *extension, zend_op_  static inline void zend_pzval_unlock_func(zval *z, zend_free_op *should_free, int unref) /* {{{ */  { -	if (!--z->refcount) { -		z->refcount = 1; -		z->is_ref = 0; +	if (!Z_DELREF_P(z)) { +		Z_SET_REFCOUNT_P(z, 1); +		Z_UNSET_ISREF_P(z);  		should_free->var = z;  /*		should_free->is_var = 1; */  	} else {  		should_free->var = 0; -		if (unref && z->is_ref && z->refcount == 1) { -			z->is_ref = 0; +		if (unref && Z_ISREF_P(z) && Z_REFCOUNT_P(z) == 1) { +			Z_UNSET_ISREF_P(z);  		}  	}  } @@ -83,7 +83,7 @@ static inline void zend_pzval_unlock_func(zval *z, zend_free_op *should_free, in  static inline void zend_pzval_unlock_free_func(zval *z) /* {{{ */  { -	if (!--z->refcount) { +	if (!Z_DELREF_P(z)) {  		zval_dtor(z);  		safe_free_zval_ptr(z);  	} @@ -93,7 +93,7 @@ static inline void zend_pzval_unlock_free_func(zval *z) /* {{{ */  #define PZVAL_UNLOCK(z, f) zend_pzval_unlock_func(z, f, 1)  #define PZVAL_UNLOCK_EX(z, f, u) zend_pzval_unlock_func(z, f, u)  #define PZVAL_UNLOCK_FREE(z) zend_pzval_unlock_free_func(z) -#define PZVAL_LOCK(z) (z)->refcount++ +#define PZVAL_LOCK(z) Z_ADDREF_P((z))  #define RETURN_VALUE_UNUSED(pzn)	(((pzn)->u.EA.type & EXT_TYPE_UNUSED))  #define SELECTIVE_PZVAL_LOCK(pzv, pzn)	if (!RETURN_VALUE_UNUSED(pzn)) { PZVAL_LOCK(pzv); } @@ -131,8 +131,8 @@ static inline void zend_pzval_unlock_free_func(zval *z) /* {{{ */  #define INIT_PZVAL_COPY(z,v) \  	(z)->value = (v)->value; \  	Z_TYPE_P(z) = Z_TYPE_P(v); \ -	(z)->refcount = 1; \ -	(z)->is_ref = 0; +	Z_SET_REFCOUNT_P((z), 1); \ +	Z_UNSET_ISREF_P(z);  #define MAKE_REAL_ZVAL_PTR(val) \  	do { \ @@ -140,8 +140,8 @@ static inline void zend_pzval_unlock_free_func(zval *z) /* {{{ */  		ALLOC_ZVAL(_tmp); \  		_tmp->value = (val)->value; \  		Z_TYPE_P(_tmp) = Z_TYPE_P(val); \ -		_tmp->refcount = 1; \ -		_tmp->is_ref = 0; \ +		Z_SET_REFCOUNT_P(_tmp, 1); \ +		Z_UNSET_ISREF_P(_tmp); \  		val = _tmp; \  	} while (0) @@ -171,7 +171,7 @@ static inline void zend_get_cv_address(zend_uchar utype, zend_compiled_variable  {  	zval *new_zval = &EG(uninitialized_zval); -	new_zval->refcount++; +	Z_ADDREF_P(new_zval);  	zend_u_hash_quick_update(EG(active_symbol_table), utype, cv->name, cv->name_len+1, cv->hash_value, &new_zval, sizeof(zval *), (void **)ptr);  }  /* }}} */ @@ -229,8 +229,8 @@ static inline zval *_get_zval_ptr_var(znode *node, temp_variable *Ts, zend_free_  			Z_TYPE_P(ptr) = IS_UNICODE;  		}  		PZVAL_UNLOCK_FREE(str); -		ptr->refcount=1; -		ptr->is_ref=1; +		Z_SET_REFCOUNT_P(ptr, 1); +		Z_SET_ISREF_P(ptr);  		return ptr;  	}  } @@ -448,35 +448,36 @@ static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **va  	} else if (variable_ptr != value_ptr) {  		if (!PZVAL_IS_REF(value_ptr)) {  			/* break it away */ -			value_ptr->refcount--; -			if (value_ptr->refcount>0) { +			Z_DELREF_P(value_ptr); +			if (Z_REFCOUNT_P(value_ptr) > 0) {  				ALLOC_ZVAL(*value_ptr_ptr);  				**value_ptr_ptr = *value_ptr;  				value_ptr = *value_ptr_ptr;  				zendi_zval_copy_ctor(*value_ptr);  			} -			value_ptr->refcount = 1; -			value_ptr->is_ref = 1; +			Z_SET_REFCOUNT_P(value_ptr, 1); +			Z_SET_ISREF_P(value_ptr);  		}  		*variable_ptr_ptr = value_ptr; -		value_ptr->refcount++; +		Z_ADDREF_P(value_ptr);  		zval_ptr_dtor(&variable_ptr); -	} else if (!variable_ptr->is_ref) { +	} else if (!Z_ISREF_P(variable_ptr)) {  		if (variable_ptr_ptr == value_ptr_ptr) {  			SEPARATE_ZVAL(variable_ptr_ptr);  		} else if (variable_ptr==EG(uninitialized_zval_ptr) -			|| variable_ptr->refcount>2) { +			|| Z_REFCOUNT_P(variable_ptr) > 2) {  			/* we need to separate */ -			variable_ptr->refcount -= 2; +			Z_DELREF_P(variable_ptr); +			Z_DELREF_P(variable_ptr);  			ALLOC_ZVAL(*variable_ptr_ptr);  			**variable_ptr_ptr = *variable_ptr;  			zval_copy_ctor(*variable_ptr_ptr);  			*value_ptr_ptr = *variable_ptr_ptr; -			(*variable_ptr_ptr)->refcount = 2; +			Z_SET_REFCOUNT_P((*variable_ptr_ptr), 2);  		} -		(*variable_ptr_ptr)->is_ref = 1; +		Z_SET_ISREF_PP(variable_ptr_ptr);  	}  }  /* }}} */ @@ -618,20 +619,20 @@ static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode  		ALLOC_ZVAL(value);  		*value = *orig_value; -		value->is_ref = 0; -		value->refcount = 0; +		Z_UNSET_ISREF_P(value); +		Z_SET_REFCOUNT_P(value, 0);  	} else if (value_op->op_type == IS_CONST) {  		zval *orig_value = value;  		ALLOC_ZVAL(value);  		*value = *orig_value; -		value->is_ref = 0; -		value->refcount = 0; +		Z_UNSET_ISREF_P(value); +		Z_SET_REFCOUNT_P(value, 0);  		zval_copy_ctor(value);  	} -	value->refcount++; +	Z_ADDREF_P(value);  	if (opcode == ZEND_ASSIGN_OBJ) {  		if (IS_TMP_FREE(free_op2)) {  			MAKE_REAL_ZVAL_PTR(property_name); @@ -809,42 +810,42 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2  	if (PZVAL_IS_REF(variable_ptr)) {  		if (variable_ptr!=value) { -			zend_uint refcount = variable_ptr->refcount; +			zend_uint refcount = Z_REFCOUNT_P(variable_ptr);  			zval garbage;  			if (type!=IS_TMP_VAR) { -				value->refcount++; +				Z_ADDREF_P(value);  			}  			garbage = *variable_ptr;  			*variable_ptr = *value; -			variable_ptr->refcount = refcount; -			variable_ptr->is_ref = 1; +			Z_SET_REFCOUNT_P(variable_ptr, refcount); +			Z_SET_ISREF_P(variable_ptr);  			if (type!=IS_TMP_VAR) {  				zendi_zval_copy_ctor(*variable_ptr); -				value->refcount--; +				Z_DELREF_P(value);  			}  			zendi_zval_dtor(garbage);  		}  	} else { -		variable_ptr->refcount--; -		if (variable_ptr->refcount==0) { +		Z_DELREF_P(variable_ptr); +		if (Z_REFCOUNT_P(variable_ptr) == 0) {  			switch (type) {  				case IS_CV:  				case IS_VAR:  					/* break missing intentionally */  				case IS_CONST:  					if (variable_ptr==value) { -						variable_ptr->refcount++; +						Z_ADDREF_P(variable_ptr);  					} else if (PZVAL_IS_REF(value)) {  						zval tmp;  						tmp = *value;  						zval_copy_ctor(&tmp); -						tmp.refcount=1; +						Z_SET_REFCOUNT(tmp, 1);  						zendi_zval_dtor(*variable_ptr);  						*variable_ptr = tmp;  					} else { -						value->refcount++; +						Z_ADDREF_P(value);  						zendi_zval_dtor(*variable_ptr);  						safe_free_zval_ptr(variable_ptr);  						*variable_ptr_ptr = value; @@ -852,7 +853,7 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2  					break;  				case IS_TMP_VAR:  					zendi_zval_dtor(*variable_ptr); -					value->refcount=1; +					Z_SET_REFCOUNT_P(value, 1);  					*variable_ptr = *value;  					break;  					EMPTY_SWITCH_DEFAULT_CASE() @@ -863,26 +864,26 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2  				case IS_VAR:  					/* break missing intentionally */  				case IS_CONST: -					if (PZVAL_IS_REF(value) && value->refcount > 0) { +					if (PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) > 0) {  						ALLOC_ZVAL(variable_ptr);  						*variable_ptr_ptr = variable_ptr;  						*variable_ptr = *value;  						zval_copy_ctor(variable_ptr); -						variable_ptr->refcount=1; +						Z_SET_REFCOUNT_P(variable_ptr, 1);  						break;  					}  					*variable_ptr_ptr = value; -					value->refcount++; +					Z_ADDREF_P(value);  					break;  				case IS_TMP_VAR:  					ALLOC_ZVAL(*variable_ptr_ptr); -					value->refcount=1; +					Z_SET_REFCOUNT_P(value, 1);  					**variable_ptr_ptr = *value;  					break;  					EMPTY_SWITCH_DEFAULT_CASE()  						}  		} -		(*variable_ptr_ptr)->is_ref=0; +		Z_UNSET_ISREF_PP(variable_ptr_ptr);  	}  done_setting_var: @@ -897,9 +898,9 @@ done_setting_var:  static inline void zend_receive(zval **variable_ptr_ptr, zval *value TSRMLS_DC) /* {{{ */  { -	(*variable_ptr_ptr)->refcount--; +	Z_DELREF_PP(variable_ptr_ptr);  	*variable_ptr_ptr = value; -	value->refcount++; +	Z_ADDREF_P(value);  }  /* }}} */ @@ -1002,7 +1003,7 @@ fetch_string_dim:  					case BP_VAR_W: {  							zval *new_zval = &EG(uninitialized_zval); -							new_zval->refcount++; +							Z_ADDREF_P(new_zval);  							zend_u_symtable_update(ht, ztype, offset_key, offset_key_length + 1, &new_zval, sizeof(zval *), (void **) &retval);  						}  						break; @@ -1040,7 +1041,7 @@ fetch_string_dim:  						case BP_VAR_W: {  							zval *new_zval = &EG(uninitialized_zval); -							new_zval->refcount++; +							Z_ADDREF_P(new_zval);  							zend_hash_index_update(ht, index, &new_zval, sizeof(zval *), (void **) &retval);  						}  						break; @@ -1108,18 +1109,18 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container  		zval **retval;  		case IS_ARRAY: -			if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) { +			if ((type==BP_VAR_W || type==BP_VAR_RW) && Z_REFCOUNT_P(container) > 1 && !PZVAL_IS_REF(container)) {  				SEPARATE_ZVAL(container_ptr);  				container = *container_ptr;  			}  			if (dim == NULL) {  				zval *new_zval = &EG(uninitialized_zval); -				new_zval->refcount++; +				Z_ADDREF_P(new_zval);  				if (zend_hash_next_index_insert(Z_ARRVAL_P(container), &new_zval, sizeof(zval *), (void **) &retval) == FAILURE) {  					zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");  					retval = &EG(error_zval_ptr); -					new_zval->refcount--; +					Z_DELREF_P(new_zval);  				}  			} else {  				retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, type TSRMLS_CC); @@ -1205,16 +1206,16 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container  				overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC);  				if (overloaded_result) { -					if (!overloaded_result->is_ref && +					if (!Z_ISREF_P(overloaded_result) &&  					    (type == BP_VAR_W || type == BP_VAR_RW  || type == BP_VAR_UNSET)) { -						if (overloaded_result->refcount > 0) { +						if (Z_REFCOUNT_P(overloaded_result) > 0) {  							zval *tmp = overloaded_result;  							ALLOC_ZVAL(overloaded_result);  							*overloaded_result = *tmp;  							zval_copy_ctor(overloaded_result); -							overloaded_result->is_ref = 0; -							overloaded_result->refcount = 0; +							Z_UNSET_ISREF_P(overloaded_result); +							Z_SET_REFCOUNT_P(overloaded_result, 0);  						}  						if (Z_TYPE_P(overloaded_result) != IS_OBJECT) {  							zend_class_entry *ce = Z_OBJCE_P(container); @@ -1229,9 +1230,9 @@ static void zend_fetch_dimension_address(temp_variable *result, zval **container  					result->var.ptr_ptr = retval;  					AI_USE_PTR(result->var);  					PZVAL_LOCK(*result->var.ptr_ptr); -				} else if ((*retval)->refcount == 0) { +				} else if (Z_REFCOUNT_PP(retval) == 0) {  					/* Destroy unused result from offsetGet() magic method */ -					(*retval)->refcount = 1; +					Z_SET_REFCOUNT_P((*retval), 1);  					zval_ptr_dtor(retval);  				}  				if (dim_is_tmp_var) { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index baf0839f3a..ebb016d396 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -137,7 +137,7 @@ void init_executor(TSRMLS_D) /* {{{ */  {  	INIT_ZVAL(EG(uninitialized_zval));  	/* trick to make uninitialized_zval never be modified, passed by ref, etc.  */ -	EG(uninitialized_zval).refcount++; +	Z_ADDREF(EG(uninitialized_zval));  	INIT_ZVAL(EG(error_zval));  	EG(uninitialized_zval_ptr)=&EG(uninitialized_zval);  	EG(error_zval_ptr)=&EG(error_zval); @@ -167,8 +167,8 @@ void init_executor(TSRMLS_D) /* {{{ */  		zval *globals;  		ALLOC_ZVAL(globals); -		globals->refcount=1; -		globals->is_ref=1; +		Z_SET_REFCOUNT_P(globals, 1); +		Z_SET_ISREF_P(globals);  		Z_TYPE_P(globals) = IS_ARRAY;  		Z_ARRVAL_P(globals) = &EG(symbol_table);  		zend_ascii_hash_update(&EG(symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL); @@ -213,7 +213,7 @@ void init_executor(TSRMLS_D) /* {{{ */  static int zval_call_destructor(zval **zv TSRMLS_DC) /* {{{ */  { -	if (Z_TYPE_PP(zv) == IS_OBJECT && (*zv)->refcount == 1) { +	if (Z_TYPE_PP(zv) == IS_OBJECT && Z_REFCOUNT_PP(zv) == 1) {  		return ZEND_HASH_APPLY_REMOVE;  	} else {  		return ZEND_HASH_APPLY_KEEP; @@ -443,12 +443,12 @@ ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */  #if DEBUG_ZEND>=2  	printf("Reducing refcount for %x (%x):  %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1);  #endif -	(*zval_ptr)->refcount--; -	if ((*zval_ptr)->refcount==0) { +	Z_DELREF_PP(zval_ptr); +	if (Z_REFCOUNT_PP(zval_ptr) == 0) {  		zval_dtor(*zval_ptr);  		safe_free_zval_ptr_rel(*zval_ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC); -	} else if ((*zval_ptr)->refcount == 1) { -		(*zval_ptr)->is_ref = 0; +	} else if (Z_REFCOUNT_PP(zval_ptr) == 1) { +		Z_UNSET_ISREF_PP(zval_ptr);  	}  }  /* }}} */ @@ -458,12 +458,12 @@ ZEND_API void _zval_internal_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{  #if DEBUG_ZEND>=2  	printf("Reducing refcount for %x (%x):  %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1);  #endif -	(*zval_ptr)->refcount--; -	if ((*zval_ptr)->refcount==0) { +	Z_DELREF_PP(zval_ptr); +	if (Z_REFCOUNT_PP(zval_ptr) == 0) {  		zval_internal_dtor(*zval_ptr);  		free(*zval_ptr); -	} else if ((*zval_ptr)->refcount == 1) { -		(*zval_ptr)->is_ref = 0; +	} else if (Z_REFCOUNT_PP(zval_ptr) == 1) { +		Z_UNSET_ISREF_PP(zval_ptr);  	}  }  /* }}} */ @@ -499,8 +499,8 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco  		MARK_CONSTANT_VISITED(p); -		refcount = p->refcount; -		is_ref = p->is_ref; +		refcount = Z_REFCOUNT_P(p); +		is_ref = Z_ISREF_P(p);  		if (!zend_u_get_constant_ex(ZEND_STR_TYPE, Z_UNIVAL_P(p), Z_UNILEN_P(p), &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {  			if ((UG(unicode) && (colon.u = u_memrchr(Z_USTRVAL_P(p), ':', Z_USTRLEN_P(p))) && colon.u > Z_USTRVAL_P(p) && *(colon.u-1) == ':') || @@ -526,8 +526,8 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco  			*p = const_value;  		} -		p->refcount = refcount; -		p->is_ref = is_ref; +		Z_SET_REFCOUNT_P(p, refcount); +		Z_SET_ISREF_TO_P(p, is_ref);  	} else if (Z_TYPE_P(p) == IS_CONSTANT_ARRAY) {  		zval **element, *new_val;  		zstr str_index; @@ -583,8 +583,8 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco  			ALLOC_ZVAL(new_val);  			*new_val = **element;  			zval_copy_ctor(new_val); -			new_val->refcount = 1; -			new_val->is_ref = 0; +			Z_SET_REFCOUNT_P(new_val, 1); +			Z_UNSET_ISREF_P(new_val);  			/* preserve this bit for inheritance */  			Z_TYPE_PP(element) |= IS_CONSTANT_INDEX; @@ -736,7 +736,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS  			fci->function_name = *tmp_real_function_name;  			SEPARATE_ZVAL_IF_NOT_REF(tmp_object_ptr);  			fci->object_pp = tmp_object_ptr; -			(*fci->object_pp)->is_ref = 1; +			Z_SET_ISREF_PP(fci->object_pp);  		}  		if (fci->object_pp && !*fci->object_pp) { @@ -998,7 +998,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS  		if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i+1)  			&& !PZVAL_IS_REF(*fci->params[i])) { -			if ((*fci->params[i])->refcount>1) { +			if (Z_REFCOUNT_PP(fci->params[i]) > 1) {  				zval *new_zval;  				if (fci->no_separation) { @@ -1022,15 +1022,15 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS  				ALLOC_ZVAL(new_zval);  				*new_zval = **fci->params[i];  				zval_copy_ctor(new_zval); -				new_zval->refcount = 1; -				(*fci->params[i])->refcount--; +				Z_SET_REFCOUNT_P(new_zval, 1); +				Z_DELREF_PP(fci->params[i]);  				*fci->params[i] = new_zval;  			} -			(*fci->params[i])->refcount++; -			(*fci->params[i])->is_ref = 1; +			Z_ADDREF_PP(fci->params[i]); +			Z_SET_ISREF_PP(fci->params[i]);  			param = *fci->params[i];  		} else if (*fci->params[i] != &EG(uninitialized_zval)) { -			(*fci->params[i])->refcount++; +			Z_ADDREF_PP(fci->params[i]);  			param = *fci->params[i];  		} else {  			ALLOC_ZVAL(param); @@ -1074,7 +1074,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS  			EG(This) = *fci->object_pp;  			if (!PZVAL_IS_REF(EG(This))) { -				EG(This)->refcount++; /* For $this pointer */ +				Z_ADDREF_P(EG(This)); /* For $this pointer */  			} else {  				zval *this_ptr; @@ -1455,12 +1455,12 @@ void execute_new_code(TSRMLS_D) /* {{{ */  	while (opline<end) {  		if (opline->op1.op_type==IS_CONST) { -			opline->op1.u.constant.is_ref = 1; -			opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */ +			Z_SET_ISREF(opline->op1.u.constant); +			Z_SET_REFCOUNT(opline->op1.u.constant, 2); /* Make sure is_ref won't be reset */  		}  		if (opline->op2.op_type==IS_CONST) { -			opline->op2.u.constant.is_ref = 1; -			opline->op2.u.constant.refcount = 2; +			Z_SET_ISREF(opline->op2.u.constant); +			Z_SET_REFCOUNT(opline->op2.u.constant, 2);  		}  		switch (opline->opcode) {  			case ZEND_GOTO: diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index b8460042e1..cdb12512f6 100755 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -281,7 +281,7 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva  	iterator = emalloc(sizeof(zend_user_iterator)); -	object->refcount++; +	Z_ADDREF_P(object);  	iterator->it.data = (void*)object;  	iterator->it.funcs = ce->iterator_funcs.funcs;  	iterator->ce = Z_OBJCE_P(object); diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 90e1133389..791437cd93 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -757,8 +757,8 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR  	retval_znode.op_type = IS_CONST;  	Z_TYPE(retval_znode.u.constant) = IS_LONG;  	Z_LVAL(retval_znode.u.constant) = 1; -	retval_znode.u.constant.is_ref = 0; -	retval_znode.u.constant.refcount = 1; +	Z_UNSET_ISREF(retval_znode.u.constant); +	Z_SET_REFCOUNT(retval_znode.u.constant, 1);  	zend_save_lexical_state(&original_lex_state TSRMLS_CC); diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 4c0ddbf345..4a76c2e2f9 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -82,7 +82,7 @@ static zval *zend_std_call_getter(zval *object, zval *member TSRMLS_DC) /* {{{ *  	zval_ptr_dtor(&member);  	if (retval) { -		retval->refcount--; +		Z_DELREF_P(retval);  	}  	return retval; @@ -96,7 +96,7 @@ static int zend_std_call_setter(zval *object, zval *member, zval *value TSRMLS_D  	zend_class_entry *ce = Z_OBJCE_P(object);  	SEPARATE_ARG_IF_REF(member); -	value->refcount++; +	Z_ADDREF_P(value);  	/* __set handler is called with two arguments:  	     property name @@ -358,16 +358,16 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC) /*  			if (rv) {  				retval = &rv; -				if (!rv->is_ref && +				if (!Z_ISREF_P(rv) &&  				    (type == BP_VAR_W || type == BP_VAR_RW  || type == BP_VAR_UNSET)) { -					if (rv->refcount > 0) { +					if (Z_REFCOUNT_P(rv) > 0) {  						zval *tmp = rv;  						ALLOC_ZVAL(rv);  						*rv = *tmp;  						zval_copy_ctor(rv); -						rv->is_ref = 0; -						rv->refcount = 0; +						Z_UNSET_ISREF_P(rv); +						Z_SET_REFCOUNT_P(rv, 0);  					}  					if (Z_TYPE_P(rv) != IS_OBJECT) {  						zend_error(E_NOTICE, "Indirect modification of overloaded property %v::$%R has no effect", zobj->ce->name, Z_TYPE_P(member), Z_UNIVAL_P(member)); @@ -384,9 +384,9 @@ zval *zend_std_read_property(zval *object, zval *member, int type TSRMLS_DC) /*  		}  	}  	if (tmp_member) { -		(*retval)->refcount++; +		Z_ADDREF_PP(retval);  		zval_ptr_dtor(&tmp_member); -		(*retval)->refcount--; +		Z_DELREF_PP(retval);  	}  	return *retval;  } @@ -423,7 +423,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM  				/* To check: can't *variable_ptr be some system variable like error_zval here? */  				Z_TYPE_PP(variable_ptr) = Z_TYPE_P(value);  				(*variable_ptr)->value = value->value; -				if (value->refcount>0) { +				if (Z_REFCOUNT_P(value) > 0) {  					zval_copy_ctor(*variable_ptr);  				}  				zval_dtor(&garbage); @@ -431,7 +431,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM  				zval *garbage = *variable_ptr;  				/* if we assign referenced variable, we should separate it */ -				value->refcount++; +				Z_ADDREF_P(value);  				if (PZVAL_IS_REF(value)) {  					SEPARATE_ZVAL(&value);  				} @@ -457,7 +457,7 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM  			zval **foo;  			/* if we assign referenced variable, we should separate it */ -			value->refcount++; +			Z_ADDREF_P(value);  			if (PZVAL_IS_REF(value)) {  				SEPARATE_ZVAL(&value);  			} @@ -495,7 +495,7 @@ zval *zend_std_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) /*  		}  		/* Undo PZVAL_LOCK() */ -		retval->refcount--; +		Z_DELREF_P(retval);  		return retval;  	} else { @@ -587,7 +587,7 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC  			new_zval = &EG(uninitialized_zval);  /* 			zend_error(E_NOTICE, "Undefined property: %R", Z_TYPE_P(member), Z_STRVAL_P(member)); */ -			new_zval->refcount++; +			Z_ADDREF_P(new_zval);  			zend_u_hash_quick_update(zobj->properties, Z_TYPE_P(member), property_info->name, property_info->name_length+1, property_info->h, &new_zval, sizeof(zval *), (void **) &retval);  		} else {  			/* we do have getter - fail and let it try again with usual get/set */ @@ -682,7 +682,7 @@ ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */  	zend_call_method_with_2_params(&this_ptr, ce, &ce->__call, ZEND_CALL_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr);  	if (method_result_ptr) { -		if (method_result_ptr->is_ref || method_result_ptr->refcount > 1) { +		if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) {  			RETVAL_ZVAL(method_result_ptr, 1, 1);  		} else {  			RETVAL_ZVAL(method_result_ptr, 0, 1); @@ -886,7 +886,7 @@ ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{  	zend_call_method_with_2_params(NULL, ce, &ce->__callstatic, ZEND_CALLSTATIC_FUNC_NAME, &method_result_ptr, method_name_ptr, method_args_ptr);  	if (method_result_ptr) { -		if (method_result_ptr->is_ref || method_result_ptr->refcount > 1) { +		if (Z_ISREF_P(method_result_ptr) || Z_REFCOUNT_P(method_result_ptr) > 1) {  			RETVAL_ZVAL(method_result_ptr, 1, 1);  		} else {  			RETVAL_ZVAL(method_result_ptr, 0, 1); @@ -1118,7 +1118,7 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists  					rv = zend_std_call_getter(object, member TSRMLS_CC);  					guard->in_get = 0;  					if (rv) { -						rv->refcount++; +						Z_ADDREF_P(rv);  						result = i_zend_is_true(rv);  						zval_ptr_dtor(&rv);  					} diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 9d00360498..4a8c724772 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -180,9 +180,9 @@ ZEND_API void zend_objects_store_del_ref(zval *zobject TSRMLS_DC) /* {{{ */  	handle = Z_OBJ_HANDLE_P(zobject); -	zobject->refcount++; +	Z_ADDREF_P(zobject);  	zend_objects_store_del_ref_by_handle(handle TSRMLS_CC); -	zobject->refcount--; +	Z_DELREF_P(zobject);  }  /* }}} */ @@ -233,7 +233,7 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR  	obj->refcount--;  #if ZEND_DEBUG_OBJECTS -	if (obj->refcount == 0) { +	if (Z_REFCOUNT_P(obj) == 0) {  		fprintf(stderr, "Deallocated object id #%d\n", handle);  	} else {  		fprintf(stderr, "Decreased refcount of object id #%d\n", handle); diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index a646f270a7..8b170c5fcc 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -427,12 +427,12 @@ int pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */  	end = opline + op_array->last;  	while (opline < end) {  		if (opline->op1.op_type == IS_CONST) { -			opline->op1.u.constant.is_ref = 1; -			opline->op1.u.constant.refcount = 2; /* Make sure is_ref won't be reset */ +			Z_SET_ISREF(opline->op1.u.constant); +			Z_SET_REFCOUNT(opline->op1.u.constant, 2); /* Make sure is_ref won't be reset */  		}  		if (opline->op2.op_type == IS_CONST) { -			opline->op2.u.constant.is_ref = 1; -			opline->op2.u.constant.refcount = 2; +			Z_SET_ISREF(opline->op2.u.constant); +			Z_SET_REFCOUNT(opline->op2.u.constant, 2);  		}  		switch (opline->opcode) {  			case ZEND_GOTO: diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 5e44279296..d9e34e72c8 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1859,7 +1859,7 @@ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_  static inline void zend_free_obj_get_result(zval *op) /* {{{ */  {  	if (op) { -		if (op->refcount == 0) { +		if (Z_REFCOUNT_P(op) == 0) {  			zval_dtor(op);  			FREE_ZVAL(op);  		} else { diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c index cafcdb4b12..15a8e04f57 100644 --- a/Zend/zend_variables.c +++ b/Zend/zend_variables.c @@ -114,7 +114,7 @@ dtor_unicode:  ZEND_API void zval_add_ref(zval **p) /* {{{ */  { -	(*p)->refcount++; +	Z_ADDREF_PP(p);  }  /* }}} */ diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9f060354bd..d4c359f2b2 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -348,13 +348,13 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -409,7 +409,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU  				zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W);  				if (object_ptr && OP1_TYPE != IS_CV && !OP1_FREE) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -456,7 +456,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -586,13 +586,13 @@ ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR|  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -676,7 +676,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -689,7 +689,7 @@ ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMP|VAR  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -743,7 +743,7 @@ ZEND_VM_HANDLER(34, ZEND_PRE_INC, VAR|CV, ANY)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		increment_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -786,7 +786,7 @@ ZEND_VM_HANDLER(35, ZEND_PRE_DEC, VAR|CV, ANY)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		decrement_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -830,7 +830,7 @@ ZEND_VM_HANDLER(36, ZEND_POST_INC, VAR|CV, ANY)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		increment_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -868,7 +868,7 @@ ZEND_VM_HANDLER(37, ZEND_POST_DEC, VAR|CV, ANY)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		decrement_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -977,7 +977,7 @@ ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, CONST|TMP|VAR|CV, ANY, int type  				case BP_VAR_W: {  						zval *new_zval = &EG(uninitialized_zval); -						new_zval->refcount++; +						Z_ADDREF_P(new_zval);  						zend_u_hash_update(target_symbol_table, Z_TYPE_P(varname), Z_UNIVAL_P(varname), Z_UNILEN_P(varname)+1, &new_zval, sizeof(zval *), (void **) &retval);  					}  					break; @@ -1237,7 +1237,7 @@ ZEND_VM_HELPER_EX(zend_fetch_property_address_read_helper, VAR|UNUSED|CV, CONST|  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -1483,7 +1483,7 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)  	if (OP2_TYPE == IS_VAR &&  	    value_ptr_ptr && -	    !(*value_ptr_ptr)->is_ref && +	    !Z_ISREF_PP(value_ptr_ptr) &&  	    opline->extended_value == ZEND_RETURNS_FUNCTION &&  	    !EX_T(opline->op2.u.var).var.fcall_returned_reference) {  		if (free_op2.var == NULL) { @@ -1631,8 +1631,8 @@ ZEND_VM_HANDLER(53, ZEND_INIT_STRING, ANY, ANY)  		Z_STRLEN_P(tmp) = 0;  		Z_TYPE_P(tmp) = IS_STRING;  	} -	tmp->refcount = 1; -	tmp->is_ref = 0; +	Z_SET_REFCOUNT_P(tmp, 1); +	Z_UNSET_ISREF_P(tmp);  	ZEND_VM_NEXT_OPCODE();  } @@ -1769,7 +1769,7 @@ ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -1867,7 +1867,7 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -2042,8 +2042,8 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)  /*	We shouldn't fix bad extensions here,      because it can break proper ones (Bug #34045)  		if (!EX(function_state).function->common.return_reference) { -			EX_T(opline->result.u.var).var.ptr->is_ref = 0; -			EX_T(opline->result.u.var).var.ptr->refcount = 1; +			Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); +			Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1);  		}  */  		if (!return_value_used) { @@ -2110,8 +2110,8 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)  		if (!return_value_used) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} else { -			EX_T(opline->result.u.var).var.ptr->is_ref = 0; -			EX_T(opline->result.u.var).var.ptr->refcount = 1; +			Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); +			Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1);  			EX_T(opline->result.u.var).var.fcall_returned_reference = 0;  		}  	} @@ -2119,9 +2119,9 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)  	if (EG(This)) {  		if (EG(exception) && IS_CTOR_CALL(EX(called_scope))) {  			if (IS_CTOR_USED(EX(called_scope))) { -				EG(This)->refcount--; +				Z_DELREF_P(EG(This));  			} -			if (EG(This)->refcount == 1) { +			if (Z_REFCOUNT_P(EG(This)) == 1) {  				zend_object_store_ctor_failed(EG(This) TSRMLS_CC);  			}  		} @@ -2199,7 +2199,7 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)  			zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");  		} -		if (OP1_TYPE == IS_VAR && !(*retval_ptr_ptr)->is_ref) { +		if (OP1_TYPE == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) {  			if (opline->extended_value == ZEND_RETURNS_FUNCTION &&  			    EX_T(opline->op1.u.var).var.fcall_returned_reference) {  			} else if (opline->extended_value == ZEND_RETURNS_NEW) { @@ -2213,7 +2213,7 @@ ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)  		}  		SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); -		(*retval_ptr_ptr)->refcount++; +		Z_ADDREF_PP(retval_ptr_ptr);  		(*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr);  	} else { @@ -2223,7 +2223,7 @@ ZEND_VM_C_LABEL(return_by_value):  		if (!IS_OP1_TMP_FREE()) { /* Not a temp var */  			if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || -			    (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { +			    (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) {  				zval *ret;  				ALLOC_ZVAL(ret); @@ -2232,7 +2232,7 @@ ZEND_VM_C_LABEL(return_by_value):  				*EG(return_value_ptr_ptr) = ret;  			} else {  				*EG(return_value_ptr_ptr) = retval_ptr; -				retval_ptr->refcount++; +				Z_ADDREF_P(retval_ptr);  			}  		} else {  			zval *ret; @@ -2333,17 +2333,17 @@ ZEND_VM_HELPER(zend_send_by_var_helper, VAR|CV, ANY)  	if (varptr == &EG(uninitialized_zval)) {  		ALLOC_ZVAL(varptr);  		INIT_ZVAL(*varptr); -		varptr->refcount = 0; +		Z_SET_REFCOUNT_P(varptr, 0);  	} else if (PZVAL_IS_REF(varptr)) {  		zval *original_var = varptr;  		ALLOC_ZVAL(varptr);  		*varptr = *original_var; -		varptr->is_ref = 0; -		varptr->refcount = 0; +		Z_UNSET_ISREF_P(varptr); +		Z_SET_REFCOUNT_P(varptr, 0);  		zval_copy_ctor(varptr);  	} -	varptr->refcount++; +	Z_ADDREF_P(varptr);  	zend_ptr_stack_push(&EG(argument_stack), varptr);  	FREE_OP1();  /* for string offsets */ @@ -2377,9 +2377,9 @@ ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR|CV, ANY)  	     EX_T(opline->op1.u.var).var.fcall_returned_reference) &&  	    varptr != &EG(uninitialized_zval) &&  	    (PZVAL_IS_REF(varptr) || -	     (varptr->refcount == 1 && (OP1_TYPE == IS_CV || free_op1.var)))) { -		varptr->is_ref = 1; -		varptr->refcount++; +	     (Z_REFCOUNT_P(varptr) == 1 && (OP1_TYPE == IS_CV || free_op1.var)))) { +		Z_SET_ISREF_P(varptr); +		Z_ADDREF_P(varptr);  		zend_ptr_stack_push(&EG(argument_stack), varptr);  	} else {  		zval *valptr; @@ -2410,7 +2410,7 @@ ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, ANY)  	SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr);  	varptr = *varptr_ptr; -	varptr->refcount++; +	Z_ADDREF_P(varptr);  	zend_ptr_stack_push(&EG(argument_stack), varptr);  	FREE_OP1_VAR_PTR(); @@ -2481,10 +2481,10 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)  			if (Z_TYPE(opline->op2.u.constant)==IS_CONSTANT_ARRAY) {  				zval_copy_ctor(default_value);  			} -			default_value->refcount=1; +			Z_SET_REFCOUNT_P(default_value, 1);  			zval_update_constant(&default_value, 0 TSRMLS_CC); -			default_value->refcount=0; -			default_value->is_ref=0; +			Z_SET_REFCOUNT_P(default_value, 0); +			Z_UNSET_ISREF_P(default_value);  			param = &default_value;  			assignment_value = default_value;  		} else { @@ -2574,7 +2574,7 @@ ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -2659,7 +2659,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)  	if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {  		zend_error_noreturn(E_ERROR, "__clone method called on non-object");  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  		FREE_OP1_IF_VAR();  		ZEND_VM_NEXT_OPCODE();  	} @@ -2674,7 +2674,7 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)  			zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");  		}  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  	}  	if (ce && clone) { @@ -2698,8 +2698,8 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)  		ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr);  		Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC);  		Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; -		EX_T(opline->result.u.var).var.ptr->refcount=1; -		EX_T(opline->result.u.var).var.ptr->is_ref=1; +		Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); +		Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr);  		if (!RETURN_VALUE_USED(opline) || EG(exception)) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} @@ -2807,7 +2807,7 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUS  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -2818,7 +2818,7 @@ ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMP|VAR|UNUS  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -3108,7 +3108,7 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, ANY)  		convert_to_text(&tmp);  		varname = &tmp;  	} else if (OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) { -		varname->refcount++; +		Z_ADDREF_P(varname);  	}  	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -3197,7 +3197,7 @@ ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|CV, CONST|TMP|VAR|CV)  								free_offset = 1;  							}  						} else if (OP2_TYPE == IS_CV || OP2_TYPE == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -3322,18 +3322,18 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)  			ce = Z_OBJCE_PP(array_ptr_ptr);  			if (!ce || ce->get_iterator == NULL) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); -				(*array_ptr_ptr)->refcount++; +				Z_ADDREF_PP(array_ptr_ptr);  			}  			array_ptr = *array_ptr_ptr;  		} else {  			if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);  				if (opline->extended_value & ZEND_FE_FETCH_BYREF) { -					(*array_ptr_ptr)->is_ref = 1; +					Z_SET_ISREF_PP(array_ptr_ptr);  				}  			}  			array_ptr = *array_ptr_ptr; -			array_ptr->refcount++; +			Z_ADDREF_P(array_ptr);  		}  	} else {  		array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); @@ -3346,12 +3346,12 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)  		} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {  			ce = Z_OBJCE_P(array_ptr);  			if (!ce || !ce->get_iterator) { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		} else {  			if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && -			    !array_ptr->is_ref && -			    array_ptr->refcount > 1) { +			    !Z_ISREF_P(array_ptr) && +			    Z_REFCOUNT_P(array_ptr) > 1) {  				zval *tmp;  				ALLOC_ZVAL(tmp); @@ -3359,7 +3359,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)  				zval_copy_ctor(tmp);  				array_ptr = tmp;  			} else { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		}  	} @@ -3392,7 +3392,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)  		if (iter->funcs->rewind) {  			iter->funcs->rewind(iter TSRMLS_CC);  			if (EG(exception)) { -				array_ptr->refcount--; +				Z_DELREF_P(array_ptr);  				zval_ptr_dtor(&array_ptr);  				if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {  					FREE_OP1_VAR_PTR(); @@ -3404,7 +3404,7 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)  		}  		is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;  		if (EG(exception)) { -			array_ptr->refcount--; +			Z_DELREF_P(array_ptr);  			zval_ptr_dtor(&array_ptr);  			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {  				FREE_OP1_VAR_PTR(); @@ -3527,7 +3527,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)  				 * In case that ever happens we need an additional flag. */  				iter->funcs->move_forward(iter TSRMLS_CC);  				if (EG(exception)) { -					array->refcount--; +					Z_DELREF_P(array);  					zval_ptr_dtor(&array);  					ZEND_VM_NEXT_OPCODE();  				} @@ -3536,7 +3536,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)  			if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {  				/* reached end of iteration */  				if (EG(exception)) { -					array->refcount--; +					Z_DELREF_P(array);  					zval_ptr_dtor(&array);  					ZEND_VM_NEXT_OPCODE();  				} @@ -3544,7 +3544,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)  			}  			iter->funcs->get_current_data(iter, &value TSRMLS_CC);  			if (EG(exception)) { -				array->refcount--; +				Z_DELREF_P(array);  				zval_ptr_dtor(&array);  				ZEND_VM_NEXT_OPCODE();  			} @@ -3556,7 +3556,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)  				if (iter->funcs->get_current_key) {  					key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC);  					if (EG(exception)) { -						array->refcount--; +						Z_DELREF_P(array);  						zval_ptr_dtor(&array);  						ZEND_VM_NEXT_OPCODE();  					} @@ -3570,9 +3570,9 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)  	if (opline->extended_value & ZEND_FE_FETCH_BYREF) {  		SEPARATE_ZVAL_IF_NOT_REF(value); -		(*value)->is_ref = 1; +		Z_SET_ISREF_PP(value);  		EX_T(opline->result.u.var).var.ptr_ptr = value; -		(*value)->refcount++; +		Z_ADDREF_PP(value);  	} else {  		EX_T(opline->result.u.var).var.ptr_ptr = value;  		PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); @@ -4056,7 +4056,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)  		EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack));  		if (EX(object)) {  			if (IS_CTOR_USED(EX(called_scope))) { -				EX(object)->refcount--; +				Z_DELREF_P(EX(object));  			}  			zval_ptr_dtor(&EX(object));  		} diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 80bfdd2e51..83c14d28d5 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -66,9 +66,9 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC)  	}  	if (op_array->uses_this && EG(This)) { -		EG(This)->refcount++; /* For $this pointer */ +		Z_ADDREF_P(EG(This)); /* For $this pointer */  		if (zend_ascii_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL)==FAILURE) { -			EG(This)->refcount--; +			Z_DELREF_P(EG(This));  		}  	} @@ -119,8 +119,8 @@ static int ZEND_INIT_STRING_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		Z_STRLEN_P(tmp) = 0;  		Z_TYPE_P(tmp) = IS_STRING;  	} -	tmp->refcount = 1; -	tmp->is_ref = 0; +	Z_SET_REFCOUNT_P(tmp, 1); +	Z_UNSET_ISREF_P(tmp);  	ZEND_VM_NEXT_OPCODE();  } @@ -209,8 +209,8 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)  /*	We shouldn't fix bad extensions here,      because it can break proper ones (Bug #34045)  		if (!EX(function_state).function->common.return_reference) { -			EX_T(opline->result.u.var).var.ptr->is_ref = 0; -			EX_T(opline->result.u.var).var.ptr->refcount = 1; +			Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); +			Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1);  		}  */  		if (!return_value_used) { @@ -277,8 +277,8 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)  		if (!return_value_used) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} else { -			EX_T(opline->result.u.var).var.ptr->is_ref = 0; -			EX_T(opline->result.u.var).var.ptr->refcount = 1; +			Z_UNSET_ISREF_P(EX_T(opline->result.u.var).var.ptr); +			Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1);  			EX_T(opline->result.u.var).var.fcall_returned_reference = 0;  		}  	} @@ -286,9 +286,9 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)  	if (EG(This)) {  		if (EG(exception) && IS_CTOR_CALL(EX(called_scope))) {  			if (IS_CTOR_USED(EX(called_scope))) { -				EG(This)->refcount--; +				Z_DELREF_P(EG(This));  			} -			if (EG(This)->refcount == 1) { +			if (Z_REFCOUNT_P(EG(This)) == 1) {  				zend_object_store_ctor_failed(EG(This) TSRMLS_CC);  			}  		} @@ -563,7 +563,7 @@ static int ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack));  		if (EX(object)) {  			if (IS_CTOR_USED(EX(called_scope))) { -				EX(object)->refcount--; +				Z_DELREF_P(EX(object));  			}  			zval_ptr_dtor(&EX(object));  		} @@ -761,10 +761,10 @@ static int ZEND_RECV_INIT_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			if (Z_TYPE(opline->op2.u.constant)==IS_CONSTANT_ARRAY) {  				zval_copy_ctor(default_value);  			} -			default_value->refcount=1; +			Z_SET_REFCOUNT_P(default_value, 1);  			zval_update_constant(&default_value, 0 TSRMLS_CC); -			default_value->refcount=0; -			default_value->is_ref=0; +			Z_SET_REFCOUNT_P(default_value, 0); +			Z_UNSET_ISREF_P(default_value);  			param = &default_value;  			assignment_value = default_value;  		} else { @@ -1316,7 +1316,7 @@ static int zend_fetch_var_address_helper_SPEC_CONST(int type, ZEND_OPCODE_HANDLE  				case BP_VAR_W: {  						zval *new_zval = &EG(uninitialized_zval); -						new_zval->refcount++; +						Z_ADDREF_P(new_zval);  						zend_u_hash_update(target_symbol_table, Z_TYPE_P(varname), Z_UNIVAL_P(varname), Z_UNILEN_P(varname)+1, &new_zval, sizeof(zval *), (void **) &retval);  					}  					break; @@ -1529,7 +1529,7 @@ static int ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");  		} -		if (IS_CONST == IS_VAR && !(*retval_ptr_ptr)->is_ref) { +		if (IS_CONST == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) {  			if (opline->extended_value == ZEND_RETURNS_FUNCTION &&  			    EX_T(opline->op1.u.var).var.fcall_returned_reference) {  			} else if (opline->extended_value == ZEND_RETURNS_NEW) { @@ -1543,7 +1543,7 @@ static int ZEND_RETURN_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); -		(*retval_ptr_ptr)->refcount++; +		Z_ADDREF_PP(retval_ptr_ptr);  		(*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr);  	} else { @@ -1553,7 +1553,7 @@ return_by_value:  		if (!0) { /* Not a temp var */  			if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || -			    (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { +			    (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) {  				zval *ret;  				ALLOC_ZVAL(ret); @@ -1562,7 +1562,7 @@ return_by_value:  				*EG(return_value_ptr_ptr) = ret;  			} else {  				*EG(return_value_ptr_ptr) = retval_ptr; -				retval_ptr->refcount++; +				Z_ADDREF_P(retval_ptr);  			}  		} else {  			zval *ret; @@ -1649,7 +1649,7 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {  		zend_error_noreturn(E_ERROR, "__clone method called on non-object");  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  		ZEND_VM_NEXT_OPCODE();  	} @@ -1664,7 +1664,7 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");  		}  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  	}  	if (ce && clone) { @@ -1688,8 +1688,8 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr);  		Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC);  		Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; -		EX_T(opline->result.u.var).var.ptr->refcount=1; -		EX_T(opline->result.u.var).var.ptr->is_ref=1; +		Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); +		Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr);  		if (!RETURN_VALUE_USED(opline) || EG(exception)) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} @@ -1937,7 +1937,7 @@ static int ZEND_UNSET_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		convert_to_text(&tmp);  		varname = &tmp;  	} else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { -		varname->refcount++; +		Z_ADDREF_P(varname);  	}  	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -2002,18 +2002,18 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			ce = Z_OBJCE_PP(array_ptr_ptr);  			if (!ce || ce->get_iterator == NULL) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); -				(*array_ptr_ptr)->refcount++; +				Z_ADDREF_PP(array_ptr_ptr);  			}  			array_ptr = *array_ptr_ptr;  		} else {  			if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);  				if (opline->extended_value & ZEND_FE_FETCH_BYREF) { -					(*array_ptr_ptr)->is_ref = 1; +					Z_SET_ISREF_PP(array_ptr_ptr);  				}  			}  			array_ptr = *array_ptr_ptr; -			array_ptr->refcount++; +			Z_ADDREF_P(array_ptr);  		}  	} else {  		array_ptr = &opline->op1.u.constant; @@ -2026,12 +2026,12 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {  			ce = Z_OBJCE_P(array_ptr);  			if (!ce || !ce->get_iterator) { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		} else {  			if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && -			    !array_ptr->is_ref && -			    array_ptr->refcount > 1) { +			    !Z_ISREF_P(array_ptr) && +			    Z_REFCOUNT_P(array_ptr) > 1) {  				zval *tmp;  				ALLOC_ZVAL(tmp); @@ -2039,7 +2039,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  				zval_copy_ctor(tmp);  				array_ptr = tmp;  			} else { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		}  	} @@ -2072,7 +2072,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (iter->funcs->rewind) {  			iter->funcs->rewind(iter TSRMLS_CC);  			if (EG(exception)) { -				array_ptr->refcount--; +				Z_DELREF_P(array_ptr);  				zval_ptr_dtor(&array_ptr);  				if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -2084,7 +2084,7 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;  		if (EG(exception)) { -			array_ptr->refcount--; +			Z_DELREF_P(array_ptr);  			zval_ptr_dtor(&array_ptr);  			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -2630,7 +2630,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HAN  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -2649,7 +2649,7 @@ static int ZEND_CASE_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -2768,7 +2768,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_A  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -2779,7 +2779,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_A  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -3184,7 +3184,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDL  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -3203,7 +3203,7 @@ static int ZEND_CASE_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -3256,7 +3256,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -3267,7 +3267,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -3634,7 +3634,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDL  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -3653,7 +3653,7 @@ static int ZEND_CASE_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -3706,7 +3706,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -3717,7 +3717,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -3850,7 +3850,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HA  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -3890,7 +3890,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -3901,7 +3901,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -4268,7 +4268,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLE  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -4287,7 +4287,7 @@ static int ZEND_CASE_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -4339,7 +4339,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -4350,7 +4350,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -4520,7 +4520,7 @@ static int zend_fetch_var_address_helper_SPEC_TMP(int type, ZEND_OPCODE_HANDLER_  				case BP_VAR_W: {  						zval *new_zval = &EG(uninitialized_zval); -						new_zval->refcount++; +						Z_ADDREF_P(new_zval);  						zend_u_hash_update(target_symbol_table, Z_TYPE_P(varname), Z_UNIVAL_P(varname), Z_UNILEN_P(varname)+1, &new_zval, sizeof(zval *), (void **) &retval);  					}  					break; @@ -4727,7 +4727,7 @@ static int ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");  		} -		if (IS_TMP_VAR == IS_VAR && !(*retval_ptr_ptr)->is_ref) { +		if (IS_TMP_VAR == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) {  			if (opline->extended_value == ZEND_RETURNS_FUNCTION &&  			    EX_T(opline->op1.u.var).var.fcall_returned_reference) {  			} else if (opline->extended_value == ZEND_RETURNS_NEW) { @@ -4741,7 +4741,7 @@ static int ZEND_RETURN_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); -		(*retval_ptr_ptr)->refcount++; +		Z_ADDREF_PP(retval_ptr_ptr);  		(*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr);  	} else { @@ -4751,7 +4751,7 @@ return_by_value:  		if (!1) { /* Not a temp var */  			if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || -			    (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { +			    (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) {  				zval *ret;  				ALLOC_ZVAL(ret); @@ -4760,7 +4760,7 @@ return_by_value:  				*EG(return_value_ptr_ptr) = ret;  			} else {  				*EG(return_value_ptr_ptr) = retval_ptr; -				retval_ptr->refcount++; +				Z_ADDREF_P(retval_ptr);  			}  		} else {  			zval *ret; @@ -4854,7 +4854,7 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {  		zend_error_noreturn(E_ERROR, "__clone method called on non-object");  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  		ZEND_VM_NEXT_OPCODE();  	} @@ -4869,7 +4869,7 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");  		}  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  	}  	if (ce && clone) { @@ -4893,8 +4893,8 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr);  		Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC);  		Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; -		EX_T(opline->result.u.var).var.ptr->refcount=1; -		EX_T(opline->result.u.var).var.ptr->is_ref=1; +		Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); +		Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr);  		if (!RETURN_VALUE_USED(opline) || EG(exception)) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} @@ -5142,7 +5142,7 @@ static int ZEND_UNSET_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		convert_to_text(&tmp);  		varname = &tmp;  	} else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { -		varname->refcount++; +		Z_ADDREF_P(varname);  	}  	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -5207,18 +5207,18 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			ce = Z_OBJCE_PP(array_ptr_ptr);  			if (!ce || ce->get_iterator == NULL) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); -				(*array_ptr_ptr)->refcount++; +				Z_ADDREF_PP(array_ptr_ptr);  			}  			array_ptr = *array_ptr_ptr;  		} else {  			if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);  				if (opline->extended_value & ZEND_FE_FETCH_BYREF) { -					(*array_ptr_ptr)->is_ref = 1; +					Z_SET_ISREF_PP(array_ptr_ptr);  				}  			}  			array_ptr = *array_ptr_ptr; -			array_ptr->refcount++; +			Z_ADDREF_P(array_ptr);  		}  	} else {  		array_ptr = _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); @@ -5231,12 +5231,12 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {  			ce = Z_OBJCE_P(array_ptr);  			if (!ce || !ce->get_iterator) { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		} else {  			if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && -			    !array_ptr->is_ref && -			    array_ptr->refcount > 1) { +			    !Z_ISREF_P(array_ptr) && +			    Z_REFCOUNT_P(array_ptr) > 1) {  				zval *tmp;  				ALLOC_ZVAL(tmp); @@ -5244,7 +5244,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  				zval_copy_ctor(tmp);  				array_ptr = tmp;  			} else { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		}  	} @@ -5277,7 +5277,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (iter->funcs->rewind) {  			iter->funcs->rewind(iter TSRMLS_CC);  			if (EG(exception)) { -				array_ptr->refcount--; +				Z_DELREF_P(array_ptr);  				zval_ptr_dtor(&array_ptr);  				if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -5289,7 +5289,7 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;  		if (EG(exception)) { -			array_ptr->refcount--; +			Z_DELREF_P(array_ptr);  			zval_ptr_dtor(&array_ptr);  			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -5844,7 +5844,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -5869,7 +5869,7 @@ static int ZEND_CASE_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -5921,7 +5921,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -5932,7 +5932,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -6295,7 +6295,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -6321,7 +6321,7 @@ static int ZEND_CASE_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -6374,7 +6374,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -6385,7 +6385,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -6748,7 +6748,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -6774,7 +6774,7 @@ static int ZEND_CASE_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -6827,7 +6827,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -6838,7 +6838,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -6921,7 +6921,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -6932,7 +6932,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -7294,7 +7294,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -7319,7 +7319,7 @@ static int ZEND_CASE_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -7371,7 +7371,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -7382,7 +7382,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -7480,7 +7480,7 @@ static int ZEND_PRE_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		increment_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -7523,7 +7523,7 @@ static int ZEND_PRE_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		decrement_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -7567,7 +7567,7 @@ static int ZEND_POST_INC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		increment_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -7605,7 +7605,7 @@ static int ZEND_POST_DEC_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		decrement_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -7714,7 +7714,7 @@ static int zend_fetch_var_address_helper_SPEC_VAR(int type, ZEND_OPCODE_HANDLER_  				case BP_VAR_W: {  						zval *new_zval = &EG(uninitialized_zval); -						new_zval->refcount++; +						Z_ADDREF_P(new_zval);  						zend_u_hash_update(target_symbol_table, Z_TYPE_P(varname), Z_UNIVAL_P(varname), Z_UNILEN_P(varname)+1, &new_zval, sizeof(zval *), (void **) &retval);  					}  					break; @@ -7915,7 +7915,7 @@ static int ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");  		} -		if (IS_VAR == IS_VAR && !(*retval_ptr_ptr)->is_ref) { +		if (IS_VAR == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) {  			if (opline->extended_value == ZEND_RETURNS_FUNCTION &&  			    EX_T(opline->op1.u.var).var.fcall_returned_reference) {  			} else if (opline->extended_value == ZEND_RETURNS_NEW) { @@ -7929,7 +7929,7 @@ static int ZEND_RETURN_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); -		(*retval_ptr_ptr)->refcount++; +		Z_ADDREF_PP(retval_ptr_ptr);  		(*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr);  	} else { @@ -7939,7 +7939,7 @@ return_by_value:  		if (!0) { /* Not a temp var */  			if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || -			    (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { +			    (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) {  				zval *ret;  				ALLOC_ZVAL(ret); @@ -7948,7 +7948,7 @@ return_by_value:  				*EG(return_value_ptr_ptr) = ret;  			} else {  				*EG(return_value_ptr_ptr) = retval_ptr; -				retval_ptr->refcount++; +				Z_ADDREF_P(retval_ptr);  			}  		} else {  			zval *ret; @@ -8021,17 +8021,17 @@ static int zend_send_by_var_helper_SPEC_VAR(ZEND_OPCODE_HANDLER_ARGS)  	if (varptr == &EG(uninitialized_zval)) {  		ALLOC_ZVAL(varptr);  		INIT_ZVAL(*varptr); -		varptr->refcount = 0; +		Z_SET_REFCOUNT_P(varptr, 0);  	} else if (PZVAL_IS_REF(varptr)) {  		zval *original_var = varptr;  		ALLOC_ZVAL(varptr);  		*varptr = *original_var; -		varptr->is_ref = 0; -		varptr->refcount = 0; +		Z_UNSET_ISREF_P(varptr); +		Z_SET_REFCOUNT_P(varptr, 0);  		zval_copy_ctor(varptr);  	} -	varptr->refcount++; +	Z_ADDREF_P(varptr);  	zend_ptr_stack_push(&EG(argument_stack), varptr);  	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};  /* for string offsets */ @@ -8065,9 +8065,9 @@ static int ZEND_SEND_VAR_NO_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	     EX_T(opline->op1.u.var).var.fcall_returned_reference) &&  	    varptr != &EG(uninitialized_zval) &&  	    (PZVAL_IS_REF(varptr) || -	     (varptr->refcount == 1 && (IS_VAR == IS_CV || free_op1.var)))) { -		varptr->is_ref = 1; -		varptr->refcount++; +	     (Z_REFCOUNT_P(varptr) == 1 && (IS_VAR == IS_CV || free_op1.var)))) { +		Z_SET_ISREF_P(varptr); +		Z_ADDREF_P(varptr);  		zend_ptr_stack_push(&EG(argument_stack), varptr);  	} else {  		zval *valptr; @@ -8098,7 +8098,7 @@ static int ZEND_SEND_REF_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr);  	varptr = *varptr_ptr; -	varptr->refcount++; +	Z_ADDREF_P(varptr);  	zend_ptr_stack_push(&EG(argument_stack), varptr);  	if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -8147,7 +8147,7 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {  		zend_error_noreturn(E_ERROR, "__clone method called on non-object");  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  		if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};  		ZEND_VM_NEXT_OPCODE();  	} @@ -8162,7 +8162,7 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");  		}  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  	}  	if (ce && clone) { @@ -8186,8 +8186,8 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr);  		Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC);  		Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; -		EX_T(opline->result.u.var).var.ptr->refcount=1; -		EX_T(opline->result.u.var).var.ptr->is_ref=1; +		Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); +		Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr);  		if (!RETURN_VALUE_USED(opline) || EG(exception)) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} @@ -8435,7 +8435,7 @@ static int ZEND_UNSET_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		convert_to_text(&tmp);  		varname = &tmp;  	} else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { -		varname->refcount++; +		Z_ADDREF_P(varname);  	}  	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -8500,18 +8500,18 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			ce = Z_OBJCE_PP(array_ptr_ptr);  			if (!ce || ce->get_iterator == NULL) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); -				(*array_ptr_ptr)->refcount++; +				Z_ADDREF_PP(array_ptr_ptr);  			}  			array_ptr = *array_ptr_ptr;  		} else {  			if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);  				if (opline->extended_value & ZEND_FE_FETCH_BYREF) { -					(*array_ptr_ptr)->is_ref = 1; +					Z_SET_ISREF_PP(array_ptr_ptr);  				}  			}  			array_ptr = *array_ptr_ptr; -			array_ptr->refcount++; +			Z_ADDREF_P(array_ptr);  		}  	} else {  		array_ptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); @@ -8524,12 +8524,12 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {  			ce = Z_OBJCE_P(array_ptr);  			if (!ce || !ce->get_iterator) { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		} else {  			if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && -			    !array_ptr->is_ref && -			    array_ptr->refcount > 1) { +			    !Z_ISREF_P(array_ptr) && +			    Z_REFCOUNT_P(array_ptr) > 1) {  				zval *tmp;  				ALLOC_ZVAL(tmp); @@ -8537,7 +8537,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  				zval_copy_ctor(tmp);  				array_ptr = tmp;  			} else { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		}  	} @@ -8570,7 +8570,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (iter->funcs->rewind) {  			iter->funcs->rewind(iter TSRMLS_CC);  			if (EG(exception)) { -				array_ptr->refcount--; +				Z_DELREF_P(array_ptr);  				zval_ptr_dtor(&array_ptr);  				if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {  					if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -8582,7 +8582,7 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;  		if (EG(exception)) { -			array_ptr->refcount--; +			Z_DELREF_P(array_ptr);  			zval_ptr_dtor(&array_ptr);  			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {  				if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; @@ -8705,7 +8705,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  				 * In case that ever happens we need an additional flag. */  				iter->funcs->move_forward(iter TSRMLS_CC);  				if (EG(exception)) { -					array->refcount--; +					Z_DELREF_P(array);  					zval_ptr_dtor(&array);  					ZEND_VM_NEXT_OPCODE();  				} @@ -8714,7 +8714,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {  				/* reached end of iteration */  				if (EG(exception)) { -					array->refcount--; +					Z_DELREF_P(array);  					zval_ptr_dtor(&array);  					ZEND_VM_NEXT_OPCODE();  				} @@ -8722,7 +8722,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			}  			iter->funcs->get_current_data(iter, &value TSRMLS_CC);  			if (EG(exception)) { -				array->refcount--; +				Z_DELREF_P(array);  				zval_ptr_dtor(&array);  				ZEND_VM_NEXT_OPCODE();  			} @@ -8734,7 +8734,7 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  				if (iter->funcs->get_current_key) {  					key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC);  					if (EG(exception)) { -						array->refcount--; +						Z_DELREF_P(array);  						zval_ptr_dtor(&array);  						ZEND_VM_NEXT_OPCODE();  					} @@ -8748,9 +8748,9 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (opline->extended_value & ZEND_FE_FETCH_BYREF) {  		SEPARATE_ZVAL_IF_NOT_REF(value); -		(*value)->is_ref = 1; +		Z_SET_ISREF_PP(value);  		EX_T(opline->result.u.var).var.ptr_ptr = value; -		(*value)->refcount++; +		Z_ADDREF_PP(value);  	} else {  		EX_T(opline->result.u.var).var.ptr_ptr = value;  		PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); @@ -9249,13 +9249,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_CONST(int (*binary_op)(zval  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -9310,7 +9310,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binary_op)(zval *re  				zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);  				if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -9357,7 +9357,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CONST(int (*binary_op)(zval *re  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -9486,13 +9486,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_CONST(incdec_t incdec_op, ZE  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -9576,7 +9576,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_t incdec_op, Z  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -9589,7 +9589,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CONST(incdec_t incdec_op, Z  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -9787,7 +9787,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_CONST(int type, ZEND  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -10065,7 +10065,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -10162,7 +10162,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDL  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -10181,7 +10181,7 @@ static int ZEND_CASE_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -10300,7 +10300,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -10311,7 +10311,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -10409,7 +10409,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -10976,13 +10976,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_TMP(int (*binary_op)(zval *  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -11037,7 +11037,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_op)(zval *resu  				zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);  				if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -11084,7 +11084,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_TMP(int (*binary_op)(zval *resu  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -11214,13 +11214,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_TMP(incdec_t incdec_op, ZEND  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -11304,7 +11304,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t incdec_op, ZEN  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -11317,7 +11317,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_TMP(incdec_t incdec_op, ZEN  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -11515,7 +11515,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_TMP(int type, ZEND_O  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -11767,7 +11767,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -11865,7 +11865,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -11884,7 +11884,7 @@ static int ZEND_CASE_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -11937,7 +11937,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -11948,7 +11948,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -12046,7 +12046,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -12613,13 +12613,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_VAR(int (*binary_op)(zval *  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -12674,7 +12674,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_op)(zval *resu  				zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);  				if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -12721,7 +12721,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_VAR(int (*binary_op)(zval *resu  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -12851,13 +12851,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_VAR(incdec_t incdec_op, ZEND  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -12941,7 +12941,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t incdec_op, ZEN  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -12954,7 +12954,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_VAR(incdec_t incdec_op, ZEN  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -13152,7 +13152,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_VAR(int type, ZEND_O  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -13371,7 +13371,7 @@ static int ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (IS_VAR == IS_VAR &&  	    value_ptr_ptr && -	    !(*value_ptr_ptr)->is_ref && +	    !Z_ISREF_PP(value_ptr_ptr) &&  	    opline->extended_value == ZEND_RETURNS_FUNCTION &&  	    !EX_T(opline->op2.u.var).var.fcall_returned_reference) {  		if (free_op2.var == NULL) { @@ -13442,7 +13442,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -13540,7 +13540,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -13559,7 +13559,7 @@ static int ZEND_CASE_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -13612,7 +13612,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -13623,7 +13623,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -13721,7 +13721,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -14054,13 +14054,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_UNUSED(int (*binary_op)(zva  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -14115,7 +14115,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*binary_op)(zval *r  				zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);  				if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -14162,7 +14162,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_UNUSED(int (*binary_op)(zval *r  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -14411,7 +14411,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HAND  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -14451,7 +14451,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -14462,7 +14462,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_AR  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -14814,13 +14814,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_VAR_CV(int (*binary_op)(zval *r  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -14875,7 +14875,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_op)(zval *resul  				zval **object_ptr = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);  				if (object_ptr && IS_VAR != IS_CV && !(free_op1.var != NULL)) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -14922,7 +14922,7 @@ static int zend_binary_assign_op_helper_SPEC_VAR_CV(int (*binary_op)(zval *resul  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -15051,13 +15051,13 @@ static int zend_pre_incdec_property_helper_SPEC_VAR_CV(incdec_t incdec_op, ZEND_  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -15141,7 +15141,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t incdec_op, ZEND  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -15154,7 +15154,7 @@ static int zend_post_incdec_property_helper_SPEC_VAR_CV(incdec_t incdec_op, ZEND  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -15352,7 +15352,7 @@ static int zend_fetch_property_address_read_helper_SPEC_VAR_CV(int type, ZEND_OP  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -15569,7 +15569,7 @@ static int ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (IS_CV == IS_VAR &&  	    value_ptr_ptr && -	    !(*value_ptr_ptr)->is_ref && +	    !Z_ISREF_PP(value_ptr_ptr) &&  	    opline->extended_value == ZEND_RETURNS_FUNCTION &&  	    !EX_T(opline->op2.u.var).var.fcall_returned_reference) {  		if (free_op2.var == NULL) { @@ -15639,7 +15639,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -15736,7 +15736,7 @@ static int ZEND_INIT_STATIC_METHOD_CALL_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_  		}  		if ((EX(object) = EG(This))) { -			EX(object)->refcount++; +			Z_ADDREF_P(EX(object));  			EX(called_scope) = Z_OBJCE_P(EX(object));  		}  	} @@ -15755,7 +15755,7 @@ static int ZEND_CASE_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -15807,7 +15807,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -15818,7 +15818,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -15916,7 +15916,7 @@ static int ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_CV == IS_CV || IS_CV == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -16194,7 +16194,7 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {  		zend_error_noreturn(E_ERROR, "__clone method called on non-object");  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  		ZEND_VM_NEXT_OPCODE();  	} @@ -16209,7 +16209,7 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");  		}  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  	}  	if (ce && clone) { @@ -16233,8 +16233,8 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr);  		Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC);  		Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; -		EX_T(opline->result.u.var).var.ptr->refcount=1; -		EX_T(opline->result.u.var).var.ptr->is_ref=1; +		Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); +		Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr);  		if (!RETURN_VALUE_USED(opline) || EG(exception)) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} @@ -16330,13 +16330,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_CONST(int (*binary_op)(z  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -16390,7 +16390,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CONST(int (*binary_op)(zval  				zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C);  				if (object_ptr && IS_UNUSED != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -16437,7 +16437,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CONST(int (*binary_op)(zval  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -16566,13 +16566,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_CONST(incdec_t incdec_op,  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -16656,7 +16656,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CONST(incdec_t incdec_op  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -16669,7 +16669,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CONST(incdec_t incdec_op  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -16739,7 +16739,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_CONST(int type, Z  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -16943,7 +16943,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_A  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -17085,7 +17085,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -17414,13 +17414,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_TMP(int (*binary_op)(zva  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -17474,7 +17474,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*binary_op)(zval *r  				zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C);  				if (object_ptr && IS_UNUSED != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -17521,7 +17521,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_TMP(int (*binary_op)(zval *r  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -17651,13 +17651,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_TMP(incdec_t incdec_op, Z  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -17741,7 +17741,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec_t incdec_op,  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -17754,7 +17754,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_TMP(incdec_t incdec_op,  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -17824,7 +17824,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_TMP(int type, ZEN  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -18028,7 +18028,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -18104,7 +18104,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -18433,13 +18433,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_VAR(int (*binary_op)(zva  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -18493,7 +18493,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*binary_op)(zval *r  				zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C);  				if (object_ptr && IS_UNUSED != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -18540,7 +18540,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_VAR(int (*binary_op)(zval *r  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -18670,13 +18670,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_VAR(incdec_t incdec_op, Z  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -18760,7 +18760,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec_t incdec_op,  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -18773,7 +18773,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_VAR(incdec_t incdec_op,  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -18843,7 +18843,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_VAR(int type, ZEN  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -19047,7 +19047,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -19123,7 +19123,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -19452,13 +19452,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -19512,7 +19512,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval  				zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C);  				if (object_ptr && IS_UNUSED != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -19559,7 +19559,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_UNUSED(int (*binary_op)(zval  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -19718,13 +19718,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_UNUSED_CV(int (*binary_op)(zval  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -19778,7 +19778,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *re  				zval **object_ptr = _get_obj_zval_ptr_ptr_unused(TSRMLS_C);  				if (object_ptr && IS_UNUSED != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -19825,7 +19825,7 @@ static int zend_binary_assign_op_helper_SPEC_UNUSED_CV(int (*binary_op)(zval *re  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -19954,13 +19954,13 @@ static int zend_pre_incdec_property_helper_SPEC_UNUSED_CV(incdec_t incdec_op, ZE  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -20044,7 +20044,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CV(incdec_t incdec_op, Z  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -20057,7 +20057,7 @@ static int zend_post_incdec_property_helper_SPEC_UNUSED_CV(incdec_t incdec_op, Z  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -20127,7 +20127,7 @@ static int zend_fetch_property_address_read_helper_SPEC_UNUSED_CV(int type, ZEND  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -20331,7 +20331,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -20406,7 +20406,7 @@ static int ZEND_UNSET_DIM_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_CV == IS_CV || IS_CV == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -20715,7 +20715,7 @@ static int ZEND_PRE_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		increment_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -20757,7 +20757,7 @@ static int ZEND_PRE_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		decrement_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -20800,7 +20800,7 @@ static int ZEND_POST_INC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		increment_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -20837,7 +20837,7 @@ static int ZEND_POST_DEC_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		val->refcount++; +		Z_ADDREF_P(val);  		decrement_function(val);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC);  		zval_ptr_dtor(&val); @@ -20944,7 +20944,7 @@ static int zend_fetch_var_address_helper_SPEC_CV(int type, ZEND_OPCODE_HANDLER_A  				case BP_VAR_W: {  						zval *new_zval = &EG(uninitialized_zval); -						new_zval->refcount++; +						Z_ADDREF_P(new_zval);  						zend_u_hash_update(target_symbol_table, Z_TYPE_P(varname), Z_UNIVAL_P(varname), Z_UNILEN_P(varname)+1, &new_zval, sizeof(zval *), (void **) &retval);  					}  					break; @@ -21140,7 +21140,7 @@ static int ZEND_RETURN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference");  		} -		if (IS_CV == IS_VAR && !(*retval_ptr_ptr)->is_ref) { +		if (IS_CV == IS_VAR && !Z_ISREF_PP(retval_ptr_ptr)) {  			if (opline->extended_value == ZEND_RETURNS_FUNCTION &&  			    EX_T(opline->op1.u.var).var.fcall_returned_reference) {  			} else if (opline->extended_value == ZEND_RETURNS_NEW) { @@ -21154,7 +21154,7 @@ static int ZEND_RETURN_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); -		(*retval_ptr_ptr)->refcount++; +		Z_ADDREF_PP(retval_ptr_ptr);  		(*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr);  	} else { @@ -21164,7 +21164,7 @@ return_by_value:  		if (!0) { /* Not a temp var */  			if (EG(active_op_array)->return_reference == ZEND_RETURN_REF || -			    (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0)) { +			    (PZVAL_IS_REF(retval_ptr) && Z_REFCOUNT_P(retval_ptr) > 0)) {  				zval *ret;  				ALLOC_ZVAL(ret); @@ -21173,7 +21173,7 @@ return_by_value:  				*EG(return_value_ptr_ptr) = ret;  			} else {  				*EG(return_value_ptr_ptr) = retval_ptr; -				retval_ptr->refcount++; +				Z_ADDREF_P(retval_ptr);  			}  		} else {  			zval *ret; @@ -21246,17 +21246,17 @@ static int zend_send_by_var_helper_SPEC_CV(ZEND_OPCODE_HANDLER_ARGS)  	if (varptr == &EG(uninitialized_zval)) {  		ALLOC_ZVAL(varptr);  		INIT_ZVAL(*varptr); -		varptr->refcount = 0; +		Z_SET_REFCOUNT_P(varptr, 0);  	} else if (PZVAL_IS_REF(varptr)) {  		zval *original_var = varptr;  		ALLOC_ZVAL(varptr);  		*varptr = *original_var; -		varptr->is_ref = 0; -		varptr->refcount = 0; +		Z_UNSET_ISREF_P(varptr); +		Z_SET_REFCOUNT_P(varptr, 0);  		zval_copy_ctor(varptr);  	} -	varptr->refcount++; +	Z_ADDREF_P(varptr);  	zend_ptr_stack_push(&EG(argument_stack), varptr);  	;  /* for string offsets */ @@ -21290,9 +21290,9 @@ static int ZEND_SEND_VAR_NO_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	     EX_T(opline->op1.u.var).var.fcall_returned_reference) &&  	    varptr != &EG(uninitialized_zval) &&  	    (PZVAL_IS_REF(varptr) || -	     (varptr->refcount == 1 && (IS_CV == IS_CV || free_op1.var)))) { -		varptr->is_ref = 1; -		varptr->refcount++; +	     (Z_REFCOUNT_P(varptr) == 1 && (IS_CV == IS_CV || free_op1.var)))) { +		Z_SET_ISREF_P(varptr); +		Z_ADDREF_P(varptr);  		zend_ptr_stack_push(&EG(argument_stack), varptr);  	} else {  		zval *valptr; @@ -21323,7 +21323,7 @@ static int ZEND_SEND_REF_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr);  	varptr = *varptr_ptr; -	varptr->refcount++; +	Z_ADDREF_P(varptr);  	zend_ptr_stack_push(&EG(argument_stack), varptr);  	ZEND_VM_NEXT_OPCODE(); @@ -21364,7 +21364,7 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {  		zend_error_noreturn(E_ERROR, "__clone method called on non-object");  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  		ZEND_VM_NEXT_OPCODE();  	} @@ -21379,7 +21379,7 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object");  		}  		EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); -		EX_T(opline->result.u.var).var.ptr->refcount++; +		Z_ADDREF_P(EX_T(opline->result.u.var).var.ptr);  	}  	if (ce && clone) { @@ -21403,8 +21403,8 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr);  		Z_OBJVAL_P(EX_T(opline->result.u.var).var.ptr) = clone_call(obj TSRMLS_CC);  		Z_TYPE_P(EX_T(opline->result.u.var).var.ptr) = IS_OBJECT; -		EX_T(opline->result.u.var).var.ptr->refcount=1; -		EX_T(opline->result.u.var).var.ptr->is_ref=1; +		Z_SET_REFCOUNT_P(EX_T(opline->result.u.var).var.ptr, 1); +		Z_SET_ISREF_P(EX_T(opline->result.u.var).var.ptr);  		if (!RETURN_VALUE_USED(opline) || EG(exception)) {  			zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);  		} @@ -21652,7 +21652,7 @@ static int ZEND_UNSET_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		convert_to_text(&tmp);  		varname = &tmp;  	} else if (IS_CV == IS_CV || IS_CV == IS_VAR) { -		varname->refcount++; +		Z_ADDREF_P(varname);  	}  	if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { @@ -21717,18 +21717,18 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			ce = Z_OBJCE_PP(array_ptr_ptr);  			if (!ce || ce->get_iterator == NULL) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); -				(*array_ptr_ptr)->refcount++; +				Z_ADDREF_PP(array_ptr_ptr);  			}  			array_ptr = *array_ptr_ptr;  		} else {  			if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) {  				SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr);  				if (opline->extended_value & ZEND_FE_FETCH_BYREF) { -					(*array_ptr_ptr)->is_ref = 1; +					Z_SET_ISREF_PP(array_ptr_ptr);  				}  			}  			array_ptr = *array_ptr_ptr; -			array_ptr->refcount++; +			Z_ADDREF_P(array_ptr);  		}  	} else {  		array_ptr = _get_zval_ptr_cv(&opline->op1, EX(Ts), BP_VAR_R TSRMLS_CC); @@ -21741,12 +21741,12 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {  			ce = Z_OBJCE_P(array_ptr);  			if (!ce || !ce->get_iterator) { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		} else {  			if ((IS_CV == IS_VAR || IS_CV == IS_CV) && -			    !array_ptr->is_ref && -			    array_ptr->refcount > 1) { +			    !Z_ISREF_P(array_ptr) && +			    Z_REFCOUNT_P(array_ptr) > 1) {  				zval *tmp;  				ALLOC_ZVAL(tmp); @@ -21754,7 +21754,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  				zval_copy_ctor(tmp);  				array_ptr = tmp;  			} else { -				array_ptr->refcount++; +				Z_ADDREF_P(array_ptr);  			}  		}  	} @@ -21787,7 +21787,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (iter->funcs->rewind) {  			iter->funcs->rewind(iter TSRMLS_CC);  			if (EG(exception)) { -				array_ptr->refcount--; +				Z_DELREF_P(array_ptr);  				zval_ptr_dtor(&array_ptr);  				if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -21799,7 +21799,7 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		}  		is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;  		if (EG(exception)) { -			array_ptr->refcount--; +			Z_DELREF_P(array_ptr);  			zval_ptr_dtor(&array_ptr);  			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) { @@ -22307,13 +22307,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_CONST(int (*binary_op)(zval  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -22367,7 +22367,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CONST(int (*binary_op)(zval *res  				zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC);  				if (object_ptr && IS_CV != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -22414,7 +22414,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CONST(int (*binary_op)(zval *res  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -22543,13 +22543,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_CONST(incdec_t incdec_op, ZEN  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -22633,7 +22633,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CONST(incdec_t incdec_op, ZE  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -22646,7 +22646,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CONST(incdec_t incdec_op, ZE  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -22844,7 +22844,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_CONST(int type, ZEND_  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -23120,7 +23120,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -23145,7 +23145,7 @@ static int ZEND_CASE_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -23197,7 +23197,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -23208,7 +23208,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -23306,7 +23306,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_CONST == IS_CV || IS_CONST == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -23869,13 +23869,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_TMP(int (*binary_op)(zval *r  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -23929,7 +23929,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_op)(zval *resul  				zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC);  				if (object_ptr && IS_CV != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -23976,7 +23976,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_TMP(int (*binary_op)(zval *resul  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -24106,13 +24106,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_TMP(incdec_t incdec_op, ZEND_  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -24196,7 +24196,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t incdec_op, ZEND  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -24209,7 +24209,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_TMP(incdec_t incdec_op, ZEND  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -24407,7 +24407,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_TMP(int type, ZEND_OP  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -24657,7 +24657,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -24683,7 +24683,7 @@ static int ZEND_CASE_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -24736,7 +24736,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -24747,7 +24747,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -24845,7 +24845,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -25408,13 +25408,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_VAR(int (*binary_op)(zval *r  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -25468,7 +25468,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_op)(zval *resul  				zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC);  				if (object_ptr && IS_CV != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -25515,7 +25515,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_VAR(int (*binary_op)(zval *resul  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -25645,13 +25645,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_VAR(incdec_t incdec_op, ZEND_  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -25735,7 +25735,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t incdec_op, ZEND  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -25748,7 +25748,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_VAR(incdec_t incdec_op, ZEND  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -25946,7 +25946,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_VAR(int type, ZEND_OP  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -26163,7 +26163,7 @@ static int ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (IS_VAR == IS_VAR &&  	    value_ptr_ptr && -	    !(*value_ptr_ptr)->is_ref && +	    !Z_ISREF_PP(value_ptr_ptr) &&  	    opline->extended_value == ZEND_RETURNS_FUNCTION &&  	    !EX_T(opline->op2.u.var).var.fcall_returned_reference) {  		if (free_op2.var == NULL) { @@ -26233,7 +26233,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -26259,7 +26259,7 @@ static int ZEND_CASE_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -26312,7 +26312,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -26323,7 +26323,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -26421,7 +26421,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_VAR == IS_CV || IS_VAR == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && @@ -26750,13 +26750,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_UNUSED(int (*binary_op)(zval  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -26810,7 +26810,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_UNUSED(int (*binary_op)(zval *re  				zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC);  				if (object_ptr && IS_CV != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -26857,7 +26857,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_UNUSED(int (*binary_op)(zval *re  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -27056,7 +27056,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARG  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -27067,7 +27067,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARG  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -27419,13 +27419,13 @@ static int zend_binary_assign_op_obj_helper_SPEC_CV_CV(int (*binary_op)(zval *re  				if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  					zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -					if (z->refcount == 0) { +					if (Z_REFCOUNT_P(z) == 0) {  						zval_dtor(z);  						FREE_ZVAL(z);  					}  					z = value;  				} -				z->refcount++; +				Z_ADDREF_P(z);  				SEPARATE_ZVAL_IF_NOT_REF(&z);  				binary_op(z, z, value TSRMLS_CC);  				switch (opline->extended_value) { @@ -27479,7 +27479,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op)(zval *result  				zval **object_ptr = _get_zval_ptr_ptr_cv(&opline->op1, EX(Ts), BP_VAR_W TSRMLS_CC);  				if (object_ptr && IS_CV != IS_CV && !0) { -					(*object_ptr)->refcount++;  /* undo the effect of get_obj_zval_ptr_ptr() */ +					Z_ADDREF_PP(object_ptr);  /* undo the effect of get_obj_zval_ptr_ptr() */  				}  				if (object_ptr && Z_TYPE_PP(object_ptr) == IS_OBJECT) { @@ -27526,7 +27526,7 @@ static int zend_binary_assign_op_helper_SPEC_CV_CV(int (*binary_op)(zval *result  	   && Z_OBJ_HANDLER_PP(var_ptr, set)) {  		/* proxy object */  		zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); -		objval->refcount++; +		Z_ADDREF_P(objval);  		binary_op(objval, objval, value TSRMLS_CC);  		Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC);  		zval_ptr_dtor(&objval); @@ -27655,13 +27655,13 @@ static int zend_pre_incdec_property_helper_SPEC_CV_CV(incdec_t incdec_op, ZEND_O  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				}  				z = value;  			} -			z->refcount++; +			Z_ADDREF_P(z);  			SEPARATE_ZVAL_IF_NOT_REF(&z);  			incdec_op(z);  			*retval = z; @@ -27745,7 +27745,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CV(incdec_t incdec_op, ZEND_  			if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get) {  				zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); -				if (z->refcount == 0) { +				if (Z_REFCOUNT_P(z) == 0) {  					zval_dtor(z);  					FREE_ZVAL(z);  				} @@ -27758,7 +27758,7 @@ static int zend_post_incdec_property_helper_SPEC_CV_CV(incdec_t incdec_op, ZEND_  			zendi_zval_copy_ctor(*z_copy);  			INIT_PZVAL(z_copy);  			incdec_op(z_copy); -			z->refcount++; +			Z_ADDREF_P(z);  			Z_OBJ_HT_P(object)->write_property(object, property, z_copy TSRMLS_CC);  			zval_ptr_dtor(&z_copy);  			zval_ptr_dtor(&z); @@ -27956,7 +27956,7 @@ static int zend_fetch_property_address_read_helper_SPEC_CV_CV(int type, ZEND_OPC  		/* here we are sure we are dealing with an object */  		*retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); -		if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { +		if (RETURN_VALUE_UNUSED(&opline->result) && (Z_REFCOUNT_PP(retval) == 0)) {  			zval_dtor(*retval);  			FREE_ZVAL(*retval);  		} else { @@ -28171,7 +28171,7 @@ static int ZEND_ASSIGN_REF_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  	if (IS_CV == IS_VAR &&  	    value_ptr_ptr && -	    !(*value_ptr_ptr)->is_ref && +	    !Z_ISREF_PP(value_ptr_ptr) &&  	    opline->extended_value == ZEND_RETURNS_FUNCTION &&  	    !EX_T(opline->op2.u.var).var.fcall_returned_reference) {  		if (free_op2.var == NULL) { @@ -28240,7 +28240,7 @@ static int ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		EX(object) = NULL;  	} else {  		if (!PZVAL_IS_REF(EX(object))) { -			EX(object)->refcount++; /* For $this pointer */ +			Z_ADDREF_P(EX(object)); /* For $this pointer */  		} else {  			zval *this_ptr;  			ALLOC_ZVAL(this_ptr); @@ -28265,7 +28265,7 @@ static int ZEND_CASE_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr);  		} else {  			switch_expr_is_overloaded = 1; -			EX_T(opline->op1.u.var).str_offset.str->refcount++; +			Z_ADDREF_P(EX_T(opline->op1.u.var).str_offset.str);  		}  	}  	is_equal_function(&EX_T(opline->result.u.var).tmp_var, @@ -28317,7 +28317,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  		if (opline->extended_value) {  			SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);  			expr_ptr = *expr_ptr_ptr; -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		} else  #endif  		if (PZVAL_IS_REF(expr_ptr)) { @@ -28328,7 +28328,7 @@ static int ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  			expr_ptr = new_expr;  			zendi_zval_copy_ctor(*expr_ptr);  		} else { -			expr_ptr->refcount++; +			Z_ADDREF_P(expr_ptr);  		}  	}  	if (offset) { @@ -28426,7 +28426,7 @@ static int ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)  								free_offset = 1;  							}  						} else if (IS_CV == IS_CV || IS_CV == IS_VAR) { -							offset->refcount++; +							Z_ADDREF_P(offset);  						}  						if (zend_u_symtable_del(ht, Z_TYPE_P(offset), offset_key, offset_len+1) == SUCCESS && diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 1376567793..cf114e95a8 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -37,9 +37,9 @@ ZEND_API void {%EXECUTOR_NAME%}(zend_op_array *op_array TSRMLS_DC)  	}  	if (op_array->uses_this && EG(This)) { -		EG(This)->refcount++; /* For $this pointer */ +		Z_ADDREF_P(EG(This)); /* For $this pointer */  		if (zend_ascii_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), NULL)==FAILURE) { -			EG(This)->refcount--; +			Z_DELREF_P(EG(This));  		}  	} diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 53ce402202..f4ea8a5790 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -38,8 +38,8 @@ static zval *com_property_read(zval *object, zval *member, int type TSRMLS_DC)  	MAKE_STD_ZVAL(return_value);  	ZVAL_NULL(return_value); -	return_value->refcount = 0; -	return_value->is_ref = 0; +	Z_SET_REFCOUNT_P(return_value, 0); +	Z_UNSET_ISREF_P(return_value);  	obj = CDNO_FETCH(object); @@ -92,8 +92,8 @@ static zval *com_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)  	MAKE_STD_ZVAL(return_value);  	ZVAL_NULL(return_value); -	return_value->refcount = 0; -	return_value->is_ref = 0; +	Z_SET_REFCOUNT_P(return_value, 0); +	Z_UNSET_ISREF_P(return_value);  	obj = CDNO_FETCH(object); diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c index 3513fa0ecd..7bff720be4 100755 --- a/ext/com_dotnet/com_persist.c +++ b/ext/com_dotnet/com_persist.c @@ -261,7 +261,7 @@ static void istream_destructor(php_istream *stm)  		return;  	} -	if (stm->refcount > 0) { +	if (Z_REFCOUNT_P(stm) > 0) {  		CoDisconnectObject((IUnknown*)stm, 0);  	} @@ -281,7 +281,7 @@ PHPAPI IStream *php_com_wrapper_export_stream(php_stream *stream TSRMLS_DC)  	memset(stm, 0, sizeof(*stm));  	stm->engine_thread = GetCurrentThreadId();  	stm->lpVtbl = &php_istream_vtbl; -	stm->refcount = 1; +	Z_SET_REFCOUNT_P(stm, 1);  	stm->stream = stream;  	zend_list_addref(stream->rsrc_id); diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index 7d8dae994f..04f870c1e7 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -427,7 +427,7 @@ static void saproxy_clone(void *object, void **clone_ptr TSRMLS_DC)  	cloneproxy = emalloc(sizeof(*cloneproxy));  	memcpy(cloneproxy, proxy, sizeof(*cloneproxy)); -	ZVAL_ADDREF(cloneproxy->zobj); +	Z_ADDREF_P(cloneproxy->zobj);  	cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval *), 0);  	clone_indices(cloneproxy, proxy, proxy->dimensions); @@ -451,7 +451,7 @@ int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index TSRMLS  		proxy->zobj = com_object;  	} -	ZVAL_ADDREF(proxy->zobj); +	Z_ADDREF_P(proxy->zobj);  	proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval *), 0);  	if (rel) { @@ -570,7 +570,7 @@ zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *objec  	I->proxy = proxy;  	I->proxy_obj = object; -	ZVAL_ADDREF(I->proxy_obj); +	Z_ADDREF_P(I->proxy_obj);  	I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);  	for (i = 0; i < proxy->dimensions; i++) { diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 9690665e93..328938528a 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -547,11 +547,11 @@ static php_dispatchex *disp_constructor(zval *object TSRMLS_DC)  	disp->engine_thread = GetCurrentThreadId();  	disp->lpVtbl = &php_dispatch_vtbl; -	disp->refcount = 1; +	Z_SET_REFCOUNT_P(disp, 1);  	if (object) -		ZVAL_ADDREF(object); +		Z_ADDREF_P(object);  	disp->object = object;  	disp->id = zend_list_insert(disp, le_dispatch); @@ -572,7 +572,7 @@ static void disp_destructor(php_dispatchex *disp)  	disp->id = 0; -	if (disp->refcount > 0) +	if (Z_REFCOUNT_P(disp) > 0)  		CoDisconnectObject((IUnknown*)disp, 0);  	zend_hash_destroy(disp->dispid_to_name); diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 69187dd956..64ecaeae37 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1757,8 +1757,8 @@ static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)  	Z_TYPE_P(object) = IS_OBJECT;  	object_init_ex(object, pce); -	object->refcount = 1; -	object->is_ref = 0; +	Z_SET_REFCOUNT_P(object, 1); +	Z_UNSET_ISREF_P(object);  	return object;  } diff --git a/ext/dom/attr.c b/ext/dom/attr.c index e50f009d24..530e89a514 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -179,7 +179,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC)  	}  	if (newval->type != IS_STRING) { -		if(newval->refcount > 1) { +		if(Z_REFCOUNT_P(newval) > 1) {  			value_copy = *newval;  			zval_copy_ctor(&value_copy);  			newval = &value_copy; diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c index d40f40aa24..f29d4e113a 100644 --- a/ext/dom/characterdata.c +++ b/ext/dom/characterdata.c @@ -86,7 +86,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval TSRMLS_DC)  	}  	if (newval->type != IS_STRING) { -		if(newval->refcount > 1) { +		if(Z_REFCOUNT_P(newval) > 1) {  			value_copy = *newval;  			zval_copy_ctor(&value_copy);  			newval = &value_copy; diff --git a/ext/dom/document.c b/ext/dom/document.c index 54bb94720d..d3c05f192e 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -218,7 +218,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)  	}  	if (newval->type != IS_STRING) { -		if(newval->refcount > 1) { +		if(Z_REFCOUNT_P(newval) > 1) {  			value_copy = *newval;  			zval_copy_ctor(&value_copy);  			newval = &value_copy; @@ -286,7 +286,7 @@ int dom_document_standalone_write(dom_object *obj, zval *newval TSRMLS_DC)  		return FAILURE;  	} -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -361,7 +361,7 @@ int dom_document_version_write(dom_object *obj, zval *newval TSRMLS_DC)  	}  	if (newval->type != IS_STRING) { -		if(newval->refcount > 1) { +		if(Z_REFCOUNT_P(newval) > 1) {  			value_copy = *newval;  			zval_copy_ctor(&value_copy);  			newval = &value_copy; @@ -404,7 +404,7 @@ int dom_document_strict_error_checking_write(dom_object *obj, zval *newval TSRML  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -447,7 +447,7 @@ int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC)  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -489,7 +489,7 @@ int dom_document_validate_on_parse_write(dom_object *obj, zval *newval TSRMLS_DC  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -532,7 +532,7 @@ int dom_document_resolve_externals_write(dom_object *obj, zval *newval TSRMLS_DC  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -575,7 +575,7 @@ int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -617,7 +617,7 @@ int dom_document_recover_write(dom_object *obj, zval *newval TSRMLS_DC)  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -660,7 +660,7 @@ int dom_document_substitue_entities_write(dom_object *obj, zval *newval TSRMLS_D  	zval value_copy;  	dom_doc_propsptr doc_prop; -	if(newval->refcount > 1) { +	if(Z_REFCOUNT_P(newval) > 1) {  		value_copy = *newval;  		zval_copy_ctor(&value_copy);  		newval = &value_copy; @@ -726,7 +726,7 @@ int dom_document_document_uri_write(dom_object *obj, zval *newval TSRMLS_DC)  	}  	if (newval->type != IS_STRING) { -		if(newval->refcount > 1) { +		if(Z_REFCOUNT_P(newval) > 1) {  			value_copy = *newval;  			zval_copy_ctor(&value_copy);  			newval = &value_copy; diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index 518af21888..8698a13ad0 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -209,7 +209,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)  				zend_hash_move_forward(nodeht);  				if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {  					curattr = *entry; -					curattr->refcount++; +					Z_ADDREF_P(curattr);  				}  			} else {  				curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node; @@ -274,7 +274,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i  	iterator = emalloc(sizeof(php_dom_iterator)); -	object->refcount++; +	Z_ADDREF_P(object);  	iterator->intern.data = (void*)object;  	iterator->intern.funcs = &php_dom_iterator_funcs; @@ -288,7 +288,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i  				zend_hash_internal_pointer_reset(nodeht);  				if (zend_hash_get_current_data(nodeht, (void **) &entry)==SUCCESS) {  					curattr = *entry; -					curattr->refcount++; +					Z_ADDREF_P(curattr);  				}  			} else {  				nodep = (xmlNode *)dom_object_get_node(objmap->baseobj); diff --git a/ext/dom/node.c b/ext/dom/node.c index 81e4e5c10c..2566bbad68 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -240,7 +240,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval TSRMLS_DC)  		case XML_CDATA_SECTION_NODE:  		case XML_PI_NODE:  			if (newval->type != IS_STRING) { -				if(newval->refcount > 1) { +				if(Z_REFCOUNT_P(newval) > 1) {  					value_copy = *newval;  					zval_copy_ctor(&value_copy);  					newval = &value_copy; @@ -700,7 +700,7 @@ int dom_node_prefix_write(dom_object *obj, zval *newval TSRMLS_DC)  				}  			}  			if (newval->type != IS_STRING) { -				if(newval->refcount > 1) { +				if(Z_REFCOUNT_P(newval) > 1) {  					value_copy = *newval;  					zval_copy_ctor(&value_copy);  					newval = &value_copy; diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 121369e690..1d5d5319fc 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -312,8 +312,8 @@ zval *dom_read_property(zval *object, zval *member, int type TSRMLS_DC)  		ret = hnd->read_func(obj, &retval TSRMLS_CC);  		if (ret == SUCCESS) {  			/* ensure we're creating a temporary variable */ -			retval->refcount = 0; -			retval->is_ref = 0; +			Z_SET_REFCOUNT_P(retval, 0); +			Z_UNSET_ISREF_P(retval);  		} else {  			retval = EG(uninitialized_zval_ptr);  		} @@ -392,8 +392,8 @@ static int dom_property_exists(zval *object, zval *member, int check_empty TSRML  		if (check_empty == 2) {  			retval = 1;  		} else if (hnd->read_func(obj, &tmp TSRMLS_CC) == SUCCESS) { -			tmp->refcount = 1; -			tmp->is_ref = 0; +			Z_SET_REFCOUNT_P(tmp, 1); +			Z_UNSET_ISREF_P(tmp);  			if (check_empty == 1) {  				retval = zend_is_true(tmp);  			} else if (check_empty == 0) { @@ -988,7 +988,7 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml  	if (basenode) {  		MAKE_STD_ZVAL(baseobj);  		baseobj->type = IS_OBJECT; -		baseobj->is_ref = 1; +		Z_SET_ISREF_P(baseobj);  		baseobj->value.obj.handle = basenode->handle;  		baseobj->value.obj.handlers = dom_get_obj_handlers(TSRMLS_C);  		zval_copy_ctor(baseobj); @@ -1194,7 +1194,7 @@ PHP_DOM_EXPORT zval *php_dom_create_object(xmlNodePtr obj, int *found, zval *wra  	if ((intern = (dom_object *) php_dom_object_get_data((void *) obj))) {  		return_value->type = IS_OBJECT; -		return_value->is_ref = 1; +		Z_SET_ISREF_P(return_value);  		return_value->value.obj.handle = intern->handle;  		return_value->value.obj.handlers = dom_get_obj_handlers(TSRMLS_C);  		zval_copy_ctor(return_value); diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c index 3380e034ce..fb57c42750 100644 --- a/ext/dom/processinginstruction.c +++ b/ext/dom/processinginstruction.c @@ -150,7 +150,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC  	}  	if (newval->type != IS_STRING) { -		if(newval->refcount > 1) { +		if(Z_REFCOUNT_P(newval) > 1) {  			value_copy = *newval;  			zval_copy_ctor(&value_copy);  			newval = &value_copy; diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 9122bd2eb0..82244e8f31 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -2345,7 +2345,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)  					MAKE_STD_ZVAL(new_elem);  					array_init(new_elem); -					ZVAL_ADDREF(*elem); +					Z_ADDREF_P(*elem);  					add_next_index_zval(new_elem, *elem);  					zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL); diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c index ffa54b44af..d30904a178 100644 --- a/ext/json/JSON_parser.c +++ b/ext/json/JSON_parser.c @@ -340,7 +340,7 @@ static void attach_zval(json_parser *json, int up, int cur, smart_str *key, int  		if (!assoc) {  			add_utf8_property_zval_ex(root, (key->len ? key->c : "_empty_"), (key->len ? (key->len + 1) : sizeof("_empty_")), child TSRMLS_CC);  #if PHP_MAJOR_VERSION >= 5 -			ZVAL_DELREF(child); +			Z_DELREF_P(child);  #endif  		} else {  			add_utf8_assoc_zval_ex(root, (key->len ? key->c : ""), (key->len ? (key->len + 1) : sizeof("")), child); @@ -467,7 +467,7 @@ int JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC) /*  						if (!assoc) {  							add_utf8_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : "_empty_"), (key.len ? (key.len + 1) : sizeof("_empty_")), mval TSRMLS_CC);  #if PHP_MAJOR_VERSION >= 5 -							ZVAL_DELREF(mval); +							Z_DELREF_P(mval);  #endif  						} else {  							add_utf8_assoc_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : ""), (key.len ? (key.len + 1) : sizeof("")), mval); @@ -589,7 +589,7 @@ int JSON_parser(zval *z, unsigned short p[], int length, int assoc TSRMLS_DC) /*  										if (!assoc) {  											add_utf8_property_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : "_empty_"), (key.len ? (key.len + 1) : sizeof("_empty_")), mval TSRMLS_CC);  #if PHP_MAJOR_VERSION >= 5 -											ZVAL_DELREF(mval); +											Z_DELREF_P(mval);  #endif  										} else {  											add_utf8_assoc_zval_ex(JSON(the_zstack)[JSON(the_top)], (key.len ? key.c : ""), (key.len ? (key.len + 1) : sizeof("")), mval); diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 7ae1f86b3c..0ab69fbca8 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -710,7 +710,7 @@ static PHP_FUNCTION(libxml_set_streams_context)  		zval_ptr_dtor(&LIBXML(stream_context));  		LIBXML(stream_context) = NULL;  	} -	ZVAL_ADDREF(arg); +	Z_ADDREF_P(arg);  	LIBXML(stream_context) = arg;  }  /* }}} */ diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index ecf2f07e1e..69f0bcb8c0 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -3192,8 +3192,8 @@ detect_end:  							string.len = Z_STRLEN_PP(hash_entry);  							ret = mbfl_buffer_converter_feed_result(convd, &string, &result);  							if (ret != NULL) { -								if ((*hash_entry)->refcount > 1) { -									ZVAL_DELREF(*hash_entry); +								if (Z_REFCOUNT_PP(hash_entry) > 1) { +									Z_DELREF_P(*hash_entry);  									MAKE_STD_ZVAL(*hash_entry);  								} else {  									zval_dtor(*hash_entry); diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 81b39b1bd8..79ff22a503 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -1112,7 +1112,7 @@ PHP_FUNCTION(mb_ereg_search_init)  	}  	MBSTRG(search_str) = *arg_str; -	ZVAL_ADDREF(MBSTRG(search_str)); +	Z_ADDREF_P(MBSTRG(search_str));  	SEPARATE_ZVAL_IF_NOT_REF(&MBSTRG(search_str));  	MBSTRG(search_pos) = 0; diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index accc9783bc..8461f27ea8 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2093,7 +2093,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,  			}  			if (result_type & MYSQL_ASSOC) {  				if (result_type & MYSQL_NUM) { -					ZVAL_ADDREF(data); +					Z_ADDREF_P(data);  				}  				if (UG(unicode)) {  					UChar *ustr; diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 5a0b3ec427..fd8b7f8244 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -354,7 +354,7 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)  		ret = hnd->read_func(obj, &retval TSRMLS_CC);  		if (ret == SUCCESS) {  			/* ensure we're creating a temporary variable */ -			retval->refcount = 0; +			Z_SET_REFCOUNT_P(retval, 0);  		} else {  			retval = EG(uninitialized_zval_ptr);  		} @@ -394,8 +394,8 @@ void mysqli_write_property(zval *object, zval *member, zval *value TSRMLS_DC)  	}  	if (ret == SUCCESS) {  		hnd->write_func(obj, value TSRMLS_CC); -		if (! PZVAL_IS_REF(value) && value->refcount == 0) { -			value->refcount++; +		if (! PZVAL_IS_REF(value) && Z_REFCOUNT_P(value) == 0) { +			Z_ADDREF_P(value);  			zval_ptr_dtor(&value);  		}  	} else { @@ -1108,7 +1108,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags  			}  			if (fetchtype & MYSQLI_ASSOC) {  				if (fetchtype & MYSQLI_NUM) { -					ZVAL_ADDREF(res); +					Z_ADDREF_P(res);  				}  				if (UG(unicode)) {  					UChar *ustr; diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 19195d2719..9bffcc5f7d 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -138,7 +138,7 @@ end_1:  		stmt->param.vars = (zval **)safe_emalloc(num_vars, sizeof(zval), 0);  		for (i = 0; i < num_vars; i++) {  			if (bind[i].buffer_type  != MYSQL_TYPE_LONG_BLOB) { -				ZVAL_ADDREF(*args[i+start]); +				Z_ADDREF_P(*args[i+start]);  				stmt->param.vars[i] = *args[i+start];  			} else {  				stmt->param.vars[i] = NULL; @@ -426,7 +426,7 @@ mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc,  		stmt->result.vars = (zval **)safe_emalloc((var_cnt), sizeof(zval), 0);  		for (i = start; i < var_cnt+start; i++) {  			ofs = i-start; -			ZVAL_ADDREF(*args[i]); +			Z_ADDREF_P(*args[i]);  			stmt->result.vars[ofs] = *args[i];  		}  	} diff --git a/ext/mysqlnd/mysqlnd_palloc.c b/ext/mysqlnd/mysqlnd_palloc.c index fba769038a..819c9def3e 100644 --- a/ext/mysqlnd/mysqlnd_palloc.c +++ b/ext/mysqlnd/mysqlnd_palloc.c @@ -76,7 +76,7 @@ PHPAPI MYSQLND_ZVAL_PCACHE* _mysqlnd_palloc_init_cache(unsigned int cache_size T  		INIT_PZVAL(&(ret->block[i].zv));  		ZVAL_NULL(&(ret->block[i].zv));  		/* Assure it will never be freed before MSHUTDOWN */ -		ZVAL_ADDREF(&(ret->block[i].zv)); +		Z_ADDREF_P(&(ret->block[i].zv));  		/* 2. Add to the free list  */  		*(--ret->free_list.last_added) = &(ret->block[i]);  	} @@ -328,7 +328,7 @@ void *mysqlnd_palloc_get_zval(MYSQLND_THD_ZVAL_PCACHE * const thd_cache, zend_bo  	} else {  		/* This will set the refcount to 1, increase it, to keep the variable */  		INIT_PZVAL(&((mysqlnd_zval *) ret)->zv); -		ZVAL_ADDREF(&(((mysqlnd_zval *)ret)->zv)); +		Z_ADDREF_P(&(((mysqlnd_zval *)ret)->zv));  	}  	DBG_INF_FMT("allocated=%d ret=%p", *allocated, ret); @@ -347,7 +347,7 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd  				thd_cache,  				thd_cache->parent? thd_cache->parent->block:NULL,  				thd_cache->parent? thd_cache->parent->last_in_block:NULL, -				*zv, ZVAL_REFCOUNT(*zv), type); +				*zv, Z_REFCOUNT_PP(zv), type);  	*copy_ctor_called = FALSE;  	/* Check whether cache is used and the zval is from the cache */  	if (!thd_cache || !(cache = thd_cache->parent) || ((char *)*zv < (char *)thd_cache->parent->block || @@ -359,7 +359,7 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd  		*/  		if (type == MYSQLND_RES_PS_BUF || type == MYSQLND_RES_PS_UNBUF) {  			; /* do nothing, zval_ptr_dtor will do the job*/ -		} else if (ZVAL_REFCOUNT(*zv) > 1) { +		} else if (Z_REFCOUNT_P(*zv) > 1) {  			/*  			  Not a prepared statement, then we have to  			  call copy_ctor and then zval_ptr_dtor() @@ -388,8 +388,8 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd  	}  	/* The zval is from our cache */ -	/* refcount is always > 1, because we call ZVAL_ADDREF(). Thus test refcount > 2 */ -	if (ZVAL_REFCOUNT(*zv) > 2) { +	/* refcount is always > 1, because we call Z_ADDREF_P(). Thus test refcount > 2 */ +	if (Z_REFCOUNT_P(*zv) > 2) {  		/*  		  Because the zval is first element in mysqlnd_zval structure, then we can  		  do upcasting from zval to mysqlnd_zval here. Because we know that this @@ -435,7 +435,7 @@ void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_THD_ZVAL_PCACHE * const thd  		++cache->put_hits;  		++cache->free_items;  		((mysqlnd_zval *)*zv)->point_type = MYSQLND_POINTS_FREE; -		ZVAL_DELREF(*zv);	/* Make it 1 */ +		Z_DELREF_P(*zv);	/* Make it 1 */  		ZVAL_NULL(*zv);  #ifdef ZTS  		memset(&((mysqlnd_zval *)*zv)->thread_id, 0, sizeof(THREAD_T)); diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 00dc46761f..19fc79ef03 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -1149,7 +1149,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_param)(MYSQLND_STMT * const stmt,  			DBG_INF_FMT("%d is of type %d", i, stmt->param_bind[i].type);  			if (stmt->param_bind[i].type != MYSQL_TYPE_LONG_BLOB) {  				/* Prevent from freeing */ -				ZVAL_ADDREF(stmt->param_bind[i].zv); +				Z_ADDREF_P(stmt->param_bind[i].zv);  				/* Don't update is_ref, or we will leak during conversion */  			} else {  				stmt->param_bind[i].zv = NULL; @@ -1197,7 +1197,7 @@ MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const stmt,  		stmt->result_bind = result_bind;  		for (i = 0; i < stmt->field_count; i++) {  			/* Prevent from freeing */ -			ZVAL_ADDREF(stmt->result_bind[i].zv);		 +			Z_ADDREF_P(stmt->result_bind[i].zv);		  			/*  			  Don't update is_ref !!! it's not our job  			  Otherwise either 009.phpt or mysqli_stmt_bind_result.phpt @@ -1499,7 +1499,7 @@ void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt TSRMLS_DC)  			  We have to separate the actual zval value of the bound  			  variable from our allocated zvals or we will face double-free  			*/ -			if (ZVAL_REFCOUNT(stmt->result_bind[i].zv) > 1) { +			if (Z_REFCOUNT_P(stmt->result_bind[i].zv) > 1) {  #ifdef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF  				zval_copy_ctor(stmt->result_bind[i].zv);  #endif diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 2d42d65469..7f037d1fdb 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -539,10 +539,10 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int flag  				}  				/* Forbid ZE to free it, we will clean it */ -				ZVAL_ADDREF(data); +				Z_ADDREF_P(data);  				if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) { -					ZVAL_ADDREF(data); +					Z_ADDREF_P(data);  				}  				if (flags & MYSQLND_FETCH_NUM) {  					zend_hash_next_index_insert(row_ht, &data, sizeof(zval *), NULL); @@ -671,10 +671,10 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,  			  Let us later know what to do with this zval. If ref_count > 1, we will just  			  decrease it, otherwise free it. zval_ptr_dtor() make this very easy job.  			*/ -			ZVAL_ADDREF(data); +			Z_ADDREF_P(data);  			if ((flags & MYSQLND_FETCH_BOTH) == MYSQLND_FETCH_BOTH) { -				ZVAL_ADDREF(data); +				Z_ADDREF_P(data);  			}  			if (flags & MYSQLND_FETCH_NUM) {  				zend_hash_next_index_insert(Z_ARRVAL_P(row), &data, sizeof(zval *), NULL); @@ -1138,7 +1138,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_field_data)(MYSQLND_RES *result, unsigned int  	*return_value = **entry;  	zval_copy_ctor(return_value); -	ZVAL_REFCOUNT(return_value) = 1; +	Z_REFCOUNT_P(return_value) = 1;  	zval_dtor(&row);  	DBG_VOID_RETURN; diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 70af334c07..d1cc08dccf 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1812,7 +1812,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg  			}  			if (fetch_mode & PHP_OCI_ASSOC) {  				if (fetch_mode & PHP_OCI_NUM) { -					ZVAL_ADDREF(element); +					Z_ADDREF_P(element);  				}  				add_u_assoc_zval(return_value, (UG(unicode) ? IS_UNICODE : IS_STRING), column->name, element);  			} diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 17a0a092c7..a5b6ff317a 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -1568,7 +1568,7 @@ PHP_FUNCTION(odbc_fetch_into)  	for(i = 0; i < result->numcols; i++) {  		ALLOC_ZVAL(tmp); -		tmp->refcount = 1; +		Z_SET_REFCOUNT_P(tmp, 1);  		Z_TYPE_P(tmp) = IS_STRING;  		Z_STRLEN_P(tmp) = 0;  		sql_c_type = SQL_C_CHAR; diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 55974c7e73..5fcf7e64d5 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -845,13 +845,13 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_uchar utype, char *s  					zend_string_to_unicode_ex(UG(utf8_conv), &u, &u_len, subpat_names[i], strlen(subpat_names[i]), &status);  					zend_u_hash_update(Z_ARRVAL_P(subpats), IS_UNICODE, ZSTR(u),  									   u_len+1, &match_sets[i], sizeof(zval *), NULL); -					ZVAL_ADDREF(match_sets[i]); +					Z_ADDREF_P(match_sets[i]);  					efree(u);  					status = U_ZERO_ERROR;  				} else {  					zend_hash_update(Z_ARRVAL_P(subpats), subpat_names[i],  									 strlen(subpat_names[i])+1, &match_sets[i], sizeof(zval *), NULL); -					ZVAL_ADDREF(match_sets[i]); +					Z_ADDREF_P(match_sets[i]);  				}  			}  			zend_hash_next_index_insert(Z_ARRVAL_P(subpats), &match_sets[i], sizeof(zval *), NULL); @@ -1961,7 +1961,7 @@ PHPAPI void  php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval *return  		/* If the entry fits our requirements */  		if ((count > 0 && !invert) ||  			(count == PCRE_ERROR_NOMATCH && invert)) { -			(*entry)->refcount++; +			Z_ADDREF_PP(entry);  			/* Add to return array */  			switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 0, NULL)) diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 42c69606ce..18f30dc35c 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -430,8 +430,8 @@ static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry  	Z_TYPE_P(object) = IS_OBJECT;  	object_init_ex(object, dbstmt_ce); -	object->refcount = 1; -	object->is_ref = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	return object;  } /* }}} */ @@ -785,7 +785,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D  					PDO_HANDLE_DBH_ERR();  					return FAILURE;  				} -				(*item)->refcount++; +				Z_ADDREF_PP(item);  				dbh->def_stmt_ctor_args = *item;  			}  			return SUCCESS; @@ -872,7 +872,7 @@ static PHP_METHOD(PDO, getAttribute)  			array_init(return_value);  			add_next_index_text(return_value, dbh->def_stmt_ce->name, 1);  			if (dbh->def_stmt_ctor_args) { -				dbh->def_stmt_ctor_args->refcount++; +				Z_ADDREF_P(dbh->def_stmt_ctor_args);  				add_next_index_zval(return_value, dbh->def_stmt_ctor_args);  			}  			return; diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 9c2b488f75..72ae4a5c5a 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -291,7 +291,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s  	param->is_param = is_param;  	if (param->driver_params) { -		ZVAL_ADDREF(param->driver_params); +		Z_ADDREF_P(param->driver_params);  	}  	if (!is_param && param->name && stmt->columns) { @@ -1061,7 +1061,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,  				case PDO_FETCH_USE_DEFAULT:  				case PDO_FETCH_BOTH:  					add_assoc_zval(return_value, stmt->columns[i].name, val); -					ZVAL_ADDREF(val); +					Z_ADDREF_P(val);  					add_next_index_zval(return_value, val);  					break; @@ -1595,7 +1595,7 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt,  		return 0;  	} -	ZVAL_ADDREF(param.parameter); +	Z_ADDREF_P(param.parameter);  	if (!really_register_bound_param(¶m, stmt, is_param TSRMLS_CC)) {  		if (param.parameter) {  			zval_ptr_dtor(&(param.parameter)); @@ -1631,7 +1631,7 @@ static PHP_METHOD(PDOStatement, bindValue)  		RETURN_FALSE;  	} -	ZVAL_ADDREF(param.parameter); +	Z_ADDREF_P(param.parameter);  	if (!really_register_bound_param(¶m, stmt, TRUE TSRMLS_CC)) {  		if (param.parameter) {  			zval_ptr_dtor(&(param.parameter)); @@ -1851,7 +1851,7 @@ int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, in  	switch (stmt->default_fetch_type) {  		case PDO_FETCH_INTO:  			if (stmt->fetch.into) { -				ZVAL_DELREF(stmt->fetch.into); +				Z_DELREF_P(stmt->fetch.into);  				stmt->fetch.into = NULL;  			}  			break; @@ -2532,8 +2532,8 @@ static zval *row_prop_or_dim_read(zval *object, zval *member, int type TSRMLS_DC  		}  	} -	return_value->refcount = 0; -	return_value->is_ref = 0; +	Z_SET_REFCOUNT_P(return_value, 0); +	Z_UNSET_ISREF_P(return_value);  	return return_value;  } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 0a402f6cb8..0ce79a14d3 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -276,8 +276,8 @@ static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_  	}  	Z_TYPE_P(object) = IS_OBJECT;  	object_init_ex(object, pce); -	object->refcount = 1; -	object->is_ref = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	return object;  }  /* }}} */ @@ -2836,13 +2836,13 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)  				"Class %v does not have a property named %R", ce->name, name_type, name);  		return;  	}	 -	refcount = (*variable_ptr)->refcount; -	is_ref = (*variable_ptr)->is_ref; +	refcount = Z_REFCOUNT_PP(variable_ptr); +	is_ref = Z_ISREF_PP(variable_ptr);  	zval_dtor(*variable_ptr);  	**variable_ptr = *value;  	zval_copy_ctor(*variable_ptr); -	(*variable_ptr)->refcount = refcount; -	(*variable_ptr)->is_ref = is_ref; +	Z_SET_REFCOUNT_PP(variable_ptr, refcount); +	Z_SET_ISREF_TO_PP(variable_ptr, is_ref);  }  /* }}} */ @@ -4150,7 +4150,7 @@ ZEND_METHOD(reflection_property, setValue)  			zval_dtor(*variable_ptr);  			(*variable_ptr)->type = value->type;  			(*variable_ptr)->value = value->value; -			if (value->refcount > 0) { +			if (Z_REFCOUNT_P(value) > 0) {  				zval_copy_ctor(*variable_ptr);  			}  			setter_done = 1; @@ -4159,7 +4159,7 @@ ZEND_METHOD(reflection_property, setValue)  	if (!setter_done) {  		zval **foo; -		value->refcount++; +		Z_ADDREF_P(value);  		if (PZVAL_IS_REF(value)) {  			SEPARATE_ZVAL(&value);  		} diff --git a/ext/session/session.c b/ext/session/session.c index 5b8885e69b..a95e784cb5 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1502,7 +1502,7 @@ static PHP_FUNCTION(session_set_save_handler)  	mdata = emalloc(sizeof(*mdata));  	for (i = 0; i < 6; i++) { -		ZVAL_ADDREF(*args[i]); +		Z_ADDREF_P(*args[i]);  		mdata->names[i] = *args[i];  	} diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 50fe65bafd..8b054673ef 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -366,8 +366,8 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements,  		}  	} -	return_value->refcount = 0; -	return_value->is_ref = 0; +	Z_SET_REFCOUNT_P(return_value, 0); +	Z_UNSET_ISREF_P(return_value);  	if (member == &tmp_zv) {  		zval_dtor(&tmp_zv); @@ -416,7 +416,7 @@ static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC)  		case IS_DOUBLE:  		case IS_NULL:  		case IS_UNICODE: -			if (value->refcount > 1) { +			if (Z_REFCOUNT_P(value) > 1) {  				value_copy = *value;  				zval_copy_ctor(&value_copy);  				value = &value_copy; @@ -537,7 +537,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo  			case IS_DOUBLE:  			case IS_NULL:  			case IS_UNICODE: -				if (value->refcount > 1) { +				if (Z_REFCOUNT_P(value) > 1) {  					value_copy = *value;  					zval_copy_ctor(&value_copy);  					value = &value_copy; @@ -722,7 +722,7 @@ static zval** sxe_property_get_adr(zval *object, zval *member TSRMLS_DC) /* {{{  		zval_ptr_dtor(&sxe->tmp);  	}  	sxe->tmp = return_value; -	return_value->is_ref  = 1; +	Z_SET_ISREF_P(return_value);  	return &sxe->tmp;  } @@ -1745,8 +1745,8 @@ static int cast_object(zval *object, int type, char *contents, void *extra TSRML  	} else {  		ZVAL_NULL(object);  	} -	object->refcount = 1; -	object->is_ref = 0; +	Z_SET_REFCOUNT_P(object, 1); +	Z_UNSET_ISREF_P(object);  	switch (type) {  		case IS_STRING: @@ -1861,7 +1861,7 @@ static zval *sxe_get_value(zval *z TSRMLS_DC)  		/* FIXME: Should not be fatal */  	} -	retval->refcount = 0; +	Z_SET_REFCOUNT_P(retval, 0);  	return retval;  } @@ -2255,7 +2255,7 @@ zend_object_iterator *php_sxe_get_iterator(zend_class_entry *ce, zval *object, i  	}  	iterator = emalloc(sizeof(php_sxe_iterator)); -	object->refcount++; +	Z_ADDREF_P(object);  	iterator->intern.data = (void*)object;  	iterator->intern.funcs = &php_sxe_iterator_funcs;  	iterator->sxe = php_sxe_fetch_object(object TSRMLS_CC); diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 4b1a2634d7..532aa9c665 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -347,8 +347,8 @@ static zend_bool soap_check_xml_ref(zval **data, xmlNodePtr node TSRMLS_DC)  			if (*data != *data_ptr) {  				zval_ptr_dtor(data);  				*data = *data_ptr; -				(*data)->is_ref = 1; -				(*data)->refcount++; +				Z_SET_ISREF_PP(data); +				Z_ADDREF_PP(data);  				return 1;  			}  		} else { @@ -1123,7 +1123,7 @@ static void set_zval_property(zval* object, char* name, zval* val TSRMLS_DC)  	old_scope = EG(scope);  	EG(scope) = Z_OBJCE_P(object); -	val->refcount--; +	Z_DELREF_P(val);  	add_property_zval(object, name, val);  	EG(scope) = old_scope;  } @@ -1554,7 +1554,7 @@ static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_e  						MAKE_STD_ZVAL(arr);  						array_init(arr); -						prop->refcount++; +						Z_ADDREF_P(prop);  						add_next_index_zval(arr, prop);  						set_zval_property(ret, (char*)trav->name, arr TSRMLS_CC);  						prop = arr; @@ -2785,18 +2785,18 @@ static zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data)  		MAKE_STD_ZVAL(soapvar);  		object_init_ex(soapvar, soap_var_class_entry);  		add_property_long(soapvar, "enc_type", enc->details.type); -		ret->refcount--; +		Z_DELREF_P(ret);  		add_property_zval(soapvar, "enc_value", ret);  		parse_namespace(type_name, &cptype, &ns);  		nsptr = xmlSearchNs(data->doc, data, BAD_CAST(ns));	  		MAKE_STD_ZVAL(tmp);  		soap_decode_string(tmp, cptype TSRMLS_CC); -		tmp->refcount--; +		Z_DELREF_P(tmp);  		add_property_zval(soapvar, "enc_stype", tmp);  		if (nsptr) {  			MAKE_STD_ZVAL(tmp);  			soap_decode_string(tmp, (char*)nsptr->href TSRMLS_CC); -			tmp->refcount--; +			Z_DELREF_P(tmp);  			add_property_zval(soapvar, "enc_ns", tmp);  		}  		efree(cptype); @@ -3528,7 +3528,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS  				zend_unicode_to_string_ex(UG(utf8_conv), &Z_STRVAL_P(tmp), &Z_STRLEN_P(tmp), Z_USTRVAL_P(cur_stype), Z_USTRLEN_P(cur_stype), &status);  				cur_stype = tmp;  			} else { -				cur_stype->refcount++; +				Z_ADDREF_P(cur_stype);  			}  		}  		if (cur_ns) { @@ -3541,7 +3541,7 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS  				zend_unicode_to_string_ex(UG(utf8_conv), &Z_STRVAL_P(tmp), &Z_STRLEN_P(tmp), Z_USTRVAL_P(cur_ns), Z_USTRLEN_P(cur_ns), &status);  				cur_ns = tmp;  			} else { -				cur_ns->refcount++; +				Z_ADDREF_P(cur_ns);  			}  		} diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c index f5cc66c790..c5ac604566 100644 --- a/ext/soap/php_packet_soap.c +++ b/ext/soap/php_packet_soap.c @@ -228,7 +228,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction  		}  		add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details TSRMLS_CC);  		if (details) { -			details->refcount--; +			Z_DELREF_P(details);  		}  		xmlFreeDoc(response);  		return FALSE; @@ -402,7 +402,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction  			zend_hash_internal_pointer_reset(Z_ARRVAL_P(return_value));  			zend_hash_get_current_data(Z_ARRVAL_P(return_value), (void**)&tmp);  			tmp = *(zval**)tmp; -			tmp->refcount++; +			Z_ADDREF_P(tmp);  			zval_dtor(return_value);  			*return_value = *tmp;  			FREE_ZVAL(tmp); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 725d5d46a5..40207c383f 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -3223,7 +3223,7 @@ PHP_METHOD(SoapClient, __call)  	    soap_headers = emalloc(sizeof(HashTable));  		zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0);  		zend_hash_next_index_insert(soap_headers, &headers, sizeof(zval*), NULL); -		ZVAL_ADDREF(headers); +		Z_ADDREF_P(headers);  		free_soap_headers = 1;  	} else{  		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid SOAP header"); @@ -3243,7 +3243,7 @@ PHP_METHOD(SoapClient, __call)  			}  			zend_hash_internal_pointer_reset(default_headers);  			while (zend_hash_get_current_data(default_headers, (void**)&tmp) == SUCCESS) { -				ZVAL_ADDREF(*tmp); +				Z_ADDREF_P(*tmp);  				zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL);  				zend_hash_move_forward(default_headers);  			} @@ -3559,7 +3559,7 @@ PHP_METHOD(SoapClient, __setSoapHeaders)  	           instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry TSRMLS_CC)) {  		ALLOC_INIT_ZVAL(client->default_headers);  		array_init(client->default_headers); -		headers->refcount++; +		Z_ADDREF_P(headers);  		add_next_index_zval(client->default_headers, headers);  	} else{  		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid SOAP header"); @@ -3631,7 +3631,7 @@ static void set_soap_fault(zval *obj, char *fault_code_ns, char *fault_code, cha  	if (fault_string != NULL) {  		MAKE_STD_ZVAL(tmp);  		soap_decode_string(tmp, fault_string TSRMLS_CC); -		tmp->refcount--; +		Z_DELREF_P(tmp);  		add_property_zval(obj, "faultstring", tmp);  		zend_update_property(zend_exception_get_default(TSRMLS_C), obj, "message", sizeof("message")-1, tmp TSRMLS_CC);  	} @@ -3641,11 +3641,11 @@ static void set_soap_fault(zval *obj, char *fault_code_ns, char *fault_code, cha  		if (fault_code_ns) {  			MAKE_STD_ZVAL(tmp);  			soap_decode_string(tmp, fault_code TSRMLS_CC); -			tmp->refcount--; +			Z_DELREF_P(tmp);  			add_property_zval(obj, "faultcode", tmp);  			MAKE_STD_ZVAL(tmp);  			soap_decode_string(tmp, fault_code_ns TSRMLS_CC); -			tmp->refcount--; +			Z_DELREF_P(tmp);  			add_property_zval(obj, "faultcodens", tmp);  		} else {  			if (soap_version == SOAP_1_1) { @@ -3671,7 +3671,7 @@ static void set_soap_fault(zval *obj, char *fault_code_ns, char *fault_code, cha  					}  					MAKE_STD_ZVAL(tmp);  					soap_decode_string(tmp, fault_code TSRMLS_CC); -					tmp->refcount--; +					Z_DELREF_P(tmp);  					add_property_zval(obj, "faultcode", tmp);  				}  			} @@ -3680,7 +3680,7 @@ static void set_soap_fault(zval *obj, char *fault_code_ns, char *fault_code, cha  	if (fault_actor != NULL) {  		MAKE_STD_ZVAL(tmp);  		soap_decode_string(tmp, fault_actor TSRMLS_CC); -		tmp->refcount--; +		Z_DELREF_P(tmp);  		add_property_zval(obj, "faultactor", tmp);  	}  	if (fault_detail != NULL) { diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 23c26db518..5578faaeb9 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -470,7 +470,7 @@ PHP_FUNCTION(spl_autoload_register)  			memcpy(lc_name.s + func_name_len, &Z_OBJ_HANDLE_PP(obj_ptr), sizeof(zend_object_handle));  			func_name_len += sizeof(zend_object_handle);  			alfi.obj = *obj_ptr; -			alfi.obj->refcount++; +			Z_ADDREF_P(alfi.obj);  			if (Z_TYPE(zfunc_name) == IS_UNICODE) {  				func_name_len /= sizeof(UChar);  				Z_STRLEN(zfunc_name) = func_name_len; diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index da554af5f9..75bab2dc41 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -152,11 +152,11 @@ static zend_object_value spl_array_object_new_ex(zend_class_entry *class_type, s  				zend_hash_copy(HASH_OF(intern->array), HASH_OF(other->array), (copy_ctor_func_t) zval_add_ref, &tmp, sizeof(zval*));  			}  			if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator) { -				ZVAL_ADDREF(other->array); +				Z_ADDREF_P(other->array);  			}  		} else {  			intern->array = orig; -			ZVAL_ADDREF(intern->array); +			Z_ADDREF_P(intern->array);  			intern->ar_flags |= SPL_ARRAY_IS_REF | SPL_ARRAY_USE_OTHER;  		}  	} else { @@ -321,22 +321,22 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval  	/* When in a write context,  	 * ZE has to be fooled into thinking this is in a reference set  	 * by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */ -	if ((type == BP_VAR_W || type == BP_VAR_RW) && !(*ret)->is_ref) { -		if ((*ret)->refcount > 1) { +	if ((type == BP_VAR_W || type == BP_VAR_RW) && !Z_ISREF_PP(ret)) { +		if (Z_REFCOUNT_PP(ret) > 1) {  			zval *newval;  			/* Separate */  			MAKE_STD_ZVAL(newval);  			*newval = **ret;  			zval_copy_ctor(newval); -			newval->refcount = 1; +			Z_SET_REFCOUNT_P(newval, 1);  			/* Replace */ -			(*ret)->refcount--; +			Z_DELREF_PP(ret);  			*ret = newval;  		} -		(*ret)->is_ref = 1; +		Z_SET_ISREF_PP(ret);  	}  	return *ret; @@ -364,7 +364,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval  	}  	if (!offset) { -		value->refcount++; +		Z_ADDREF_P(value);  		zend_hash_next_index_insert(spl_array_get_hash_table(intern, 0 TSRMLS_CC), (void**)&value, sizeof(void*), NULL);  		return;  	} @@ -376,7 +376,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval  			zend_throw_exception(spl_ce_InvalidArgumentException, "An offset must not begin with \\0 or be empty", 0 TSRMLS_CC);  			return;  		} -		value->refcount++; +		Z_ADDREF_P(value);  		zend_u_symtable_update(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_TYPE_P(offset), Z_UNIVAL_P(offset), Z_UNILEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);  		return;  	case IS_DOUBLE: @@ -388,11 +388,11 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval  		} else {  			index = Z_LVAL_P(offset);  		} -		value->refcount++; +		Z_ADDREF_P(value);  		zend_hash_index_update(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index, (void**)&value, sizeof(void*), NULL);  		return;  	case IS_NULL: -		value->refcount++; +		Z_ADDREF_P(value);  		zend_hash_next_index_insert(spl_array_get_hash_table(intern, 0 TSRMLS_CC), (void**)&value, sizeof(void*), NULL);  		return;  	default: @@ -913,7 +913,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,  	iterator     = emalloc(sizeof(spl_array_it)); -	object->refcount++; +	Z_ADDREF_P(object);  	iterator->intern.it.data = (void*)object;  	iterator->intern.it.funcs = &spl_array_it_funcs;  	iterator->intern.ce = ce; @@ -982,7 +982,7 @@ SPL_METHOD(Array, __construct)  		intern->ar_flags &= ~SPL_ARRAY_IS_SELF;  	}  	intern->ar_flags |= ar_flags; -	ZVAL_ADDREF(intern->array); +	Z_ADDREF_P(intern->array);  	if (Z_TYPE_PP(array) == IS_OBJECT) {  		zend_object_get_properties_t handler = Z_OBJ_HANDLER_PP(array, get_properties);  		if ((handler != std_object_handlers.get_properties && handler != spl_array_get_properties) @@ -1089,7 +1089,7 @@ SPL_METHOD(Array, exchangeArray)  	} else {  		intern->ar_flags &= ~SPL_ARRAY_IS_SELF;  	} -	ZVAL_ADDREF(intern->array); +	Z_ADDREF_P(intern->array);  	spl_array_rewind(intern TSRMLS_CC);  } @@ -1111,8 +1111,8 @@ SPL_METHOD(Array, getIterator)  	return_value->type = IS_OBJECT;  	return_value->value.obj = spl_array_object_new_ex(intern->ce_get_iterator, &iterator, object, 0 TSRMLS_CC); -	return_value->refcount = 1; -	return_value->is_ref = 1; +	Z_SET_REFCOUNT_P(return_value, 1); +	Z_SET_ISREF_P(return_value);  }  /* }}} */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index d13dfa7ea3..e6b66cfcfb 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -270,7 +270,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu  	/* 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)); -	intern->u.file.zresource.refcount = 1; +	Z_SET_REFCOUNT(intern->u.file.zresource, 1);  	intern->u.file.delimiter = ',';  	intern->u.file.enclosure = '"'; @@ -1325,7 +1325,8 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval  	dir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);  	iterator   = spl_filesystem_object_to_iterator(dir_object); -	object->refcount += 2; +	Z_ADDREF_P(object); +	Z_ADDREF_P(object);  	iterator->intern.data = (void*)object;  	iterator->intern.funcs = &spl_filesystem_dir_it_funcs;  	iterator->current = object; @@ -1521,7 +1522,7 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva  	dir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);  	iterator   = spl_filesystem_object_to_iterator(dir_object); -	object->refcount++; +	Z_ADDREF_P(object);  	iterator->intern.data = (void*)object;  	iterator->intern.funcs = &spl_filesystem_tree_it_funcs;  	iterator->current = NULL; diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c index 9404e8e24c..f1a0e21cdf 100755 --- a/ext/spl/spl_engine.c +++ b/ext/spl/spl_engine.c @@ -38,8 +38,8 @@ PHPAPI void spl_instantiate(zend_class_entry *pce, zval **object, int alloc TSRM  		ALLOC_ZVAL(*object);  	}  	object_init_ex(*object, pce); -	(*object)->refcount = 1; -	(*object)->is_ref = 1; /* check if this can be hold always */ +	Z_SET_REFCOUNT_P((*object), 1); +	Z_SET_ISREF_PP(object); /* check if this can be hold always */  }  /* }}} */ diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 8fb31f8e6e..c983b4c879 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -392,7 +392,7 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,  	iterator = emalloc(sizeof(spl_recursive_it_iterator));  	object   = (spl_recursive_it_object*)zend_object_store_get_object(zobject TSRMLS_CC); -	zobject->refcount++; +	Z_ADDREF_P(zobject);  	iterator->intern.data = (void*)object;  	iterator->intern.funcs = ce->iterator_funcs.funcs;  	iterator->zobject = zobject; @@ -479,7 +479,7 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)  	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 TSRMLS_CC);  	if (inc_refcount) { -		iterator->refcount++; +		Z_ADDREF_P(iterator);  	}  	intern->iterators[0].zobject = iterator;  	intern->iterators[0].ce = ce_iterator; @@ -1045,7 +1045,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z  	php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC);  	if (inc_refcount) { -		zobject->refcount++; +		Z_ADDREF_P(zobject);  	}  	intern->inner.zobject = zobject;  	intern->inner.ce = dit_type == DIT_IteratorIterator ? ce : Z_OBJCE_P(zobject); @@ -1136,7 +1136,7 @@ static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more T  	if (!check_more || spl_dual_it_valid(intern TSRMLS_CC) == SUCCESS) {  		intern->inner.iterator->funcs->get_current_data(intern->inner.iterator, &data TSRMLS_CC);  		intern->current.data = *data; -		intern->current.data->refcount++; +		Z_ADDREF_P(intern->current.data);  		if (intern->inner.iterator->funcs->get_current_key) {  			intern->current.key_type = intern->inner.iterator->funcs->get_current_key(intern->inner.iterator, &intern->current.str_key, &intern->current.str_key_len, &intern->current.int_key TSRMLS_CC);  		} else { @@ -2093,7 +2093,7 @@ SPL_METHOD(CachingIterator, offsetSet)  		return;  	} -	value->refcount++; +	Z_ADDREF_P(value);  	zend_u_symtable_update(HASH_OF(intern->u.caching.zcache), type, arKey, nKeyLength+1, &value, sizeof(value), NULL);  }  /* }}} */ @@ -2551,7 +2551,7 @@ int spl_append_it_next_iterator(spl_dual_it_object *intern TSRMLS_DC) /* {{{*/  		zval **it;  		intern->u.append.iterator->funcs->get_current_data(intern->u.append.iterator, &it TSRMLS_CC); -		(*it)->refcount++; +		Z_ADDREF_PP(it);  		intern->inner.zobject = *it;  		intern->inner.ce = Z_OBJCE_PP(it);  		intern->inner.object = zend_object_store_get_object(*it TSRMLS_CC); @@ -2749,7 +2749,7 @@ static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser T  		if (EG(exception)) {  			return ZEND_HASH_APPLY_STOP;  		} -		(*data)->refcount++; +		Z_ADDREF_PP(data);  		switch(key_type) {  			case HASH_KEY_IS_STRING:  				add_assoc_zval_ex(return_value, str_key.s, str_key_len, *data); @@ -2764,7 +2764,7 @@ static int spl_iterator_to_array_apply(zend_object_iterator *iter, void *puser T  				break;  		}  	} else { -		(*data)->refcount++; +		Z_ADDREF_PP(data);  		add_next_index_zval(return_value, *data);  	}  	return ZEND_HASH_APPLY_KEEP; @@ -2779,7 +2779,7 @@ static int spl_iterator_to_values_apply(zend_object_iterator *iter, void *puser  	if (EG(exception)) {  		return ZEND_HASH_APPLY_STOP;  	} -	(*data)->refcount++; +	Z_ADDREF_PP(data);  	add_next_index_zval(return_value, *data);  	return ZEND_HASH_APPLY_KEEP;  } diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index c926dc0be6..90398a566b 100755 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -175,7 +175,7 @@ void spl_object_storage_attach(spl_SplObjectStorage *intern, zval *obj TSRMLS_DC  	}  #endif -	obj->refcount++; +	Z_ADDREF_P(obj);  } /* }}} */  /* {{{ proto void SplObjectStorage::attach($obj) U diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index b29c56cca2..e0c636dab3 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -703,7 +703,7 @@ static void php_sqlite_agg_step_function_callback(sqlite_func *func, int argc, c  	if (*context_p == NULL) {  		MAKE_STD_ZVAL(*context_p); -		(*context_p)->is_ref = 1; +		Z_SET_ISREF_PP(context_p);  		Z_TYPE_PP(context_p) = IS_NULL;  	} @@ -981,8 +981,8 @@ static zval * sqlite_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)  	}  	Z_TYPE_P(object) = IS_OBJECT;  	object_init_ex(object, pce); -	object->refcount = 1; -	object->is_ref = 0; +	Z_SET_REFCOUNT_P(object, 1); +	Z_UNSET_ISREF_P(object);  	return object;  } @@ -1100,7 +1100,7 @@ zend_object_iterator *sqlite_get_iterator(zend_class_entry *ce, zval *object, in  	iterator = emalloc(sizeof(sqlite_object_iterator)); -	object->refcount++; +	Z_ADDREF_P(object);  	iterator->it.data = (void*)object;  	iterator->it.funcs = ce->iterator_funcs.funcs;  	iterator->res = obj->u.res; @@ -1841,10 +1841,10 @@ PHP_FUNCTION(sqlite_fetch_column_types)  		MAKE_STD_ZVAL(coltype);  		ZVAL_U_STRING(SQLITE2_CONV, coltype, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", ZSTR_DUPLICATE); -		coltype->refcount = 0; +		Z_SET_REFCOUNT_P(coltype, 0);  		if (result_type == PHPSQLITE_NUM) { -			ZVAL_ADDREF(coltype); +			Z_ADDREF_P(coltype);  			add_index_zval(return_value, i, coltype);  		} @@ -1887,14 +1887,14 @@ PHP_FUNCTION(sqlite_fetch_column_types)  				}  			} -			ZVAL_ADDREF(coltype); +			Z_ADDREF_P(coltype);  			add_u_assoc_zval_ex(return_value, colname_type, colname, colname_len + 1, coltype);  			efree(colname.v);  		} -		if (coltype->refcount <= 0) { +		if (Z_REFCOUNT_P(coltype) <= 0) {  			/* Shouldn't happen (and probably can't) */ -			coltype->refcount = 1; +			Z_SET_REFCOUNT_P(coltype, 1);  			zval_ptr_dtor(&coltype);  		}  	} @@ -2049,17 +2049,17 @@ static void php_sqlite_fetch_array(struct php_sqlite_result *res, int mode, zend  				rowdata[j] = NULL;  			}  		} -		decoded->refcount = 0; +		Z_SET_REFCOUNT_P(decoded, 0);  		if (mode & PHPSQLITE_NUM) { -			ZVAL_ADDREF(decoded); +			Z_ADDREF_P(decoded);  			add_index_zval(return_value, j, decoded);  		}  		if ((mode & PHPSQLITE_ASSOC) || (!(mode & PHPSQLITE_NUM))) {  			UChar *colname;  			int colname_len; -			ZVAL_ADDREF(decoded); +			Z_ADDREF_P(decoded);  			if (UG(unicode) &&  				SUCCESS == zend_string_to_unicode(SQLITE2_CONV, &colname, &colname_len, (char*)colnames[j], strlen((char*)colnames[j]) TSRMLS_CC)) { diff --git a/ext/standard/array.c b/ext/standard/array.c index f9b2eedbbf..eda9dfc88c 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1528,10 +1528,10 @@ PHP_FUNCTION(extract)  					*orig_var = *entry;  				} else { -					if (var_array->refcount > 1 || *entry == EG(uninitialized_zval_ptr)) { +					if (Z_REFCOUNT_P(var_array) > 1 || *entry == EG(uninitialized_zval_ptr)) {  						SEPARATE_ZVAL_TO_MAKE_IS_REF(entry);  					} else { -						(*entry)->is_ref = 1; +						Z_SET_ISREF_PP(entry);  					}  					zval_add_ref(entry);  					zend_u_hash_update(EG(active_symbol_table), Z_TYPE(final_name), Z_UNIVAL(final_name), Z_UNILEN(final_name)+1, (void **) entry, sizeof(zval *), NULL); @@ -2014,7 +2014,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,  	for (pos=0, p=in_hash->pListHead; pos<offset && p ; pos++, p=p->pListNext) {  		/* Get entry and increase reference count */  		entry = *((zval **)p->pData); -		entry->refcount++; +		Z_ADDREF_P(entry);  		/* Update output hash depending on key type */  		if (p->nKeyLength == 0) { @@ -2028,7 +2028,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,  	if (removed != NULL) {  		for ( ; pos<offset+length && p; pos++, p=p->pListNext) {  			entry = *((zval **)p->pData); -			entry->refcount++; +			Z_ADDREF_P(entry);  			if (p->nKeyLength == 0) {  				zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL);  			} else {			 @@ -2043,7 +2043,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,  		/* ..for each one, create a new zval, copy entry into it and copy it into the output hash */  		for (i=0; i<list_count; i++) {  			entry = *list[i]; -			entry->refcount++; +			Z_ADDREF_P(entry);  			zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);  		}  	} @@ -2051,7 +2051,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list,  	/* Copy the remaining input hash entries to the output hash */  	for ( ; p ; p=p->pListNext) {  		entry = *((zval **)p->pData); -		entry->refcount++; +		Z_ADDREF_P(entry);  		if (p->nKeyLength == 0) {  			zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);  		} else { @@ -2098,7 +2098,7 @@ PHP_FUNCTION(array_push)  	/* For each subsequent argument, make it a reference, increase refcount, and add it to the end of the array */  	for (i=1; i<argc; i++) {  		new_var = *args[i]; -		new_var->refcount++; +		Z_ADDREF_P(new_var);  		zend_hash_next_index_insert(Z_ARRVAL_P(stack), &new_var, sizeof(zval *), NULL);  	} @@ -2402,7 +2402,7 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS  ukey:  				if (recursive &&  					zend_u_hash_find(dest, utype, string_key, string_key_len, (void **)&dest_entry) == SUCCESS) { -					if (*src_entry == *dest_entry && ((*dest_entry)->refcount % 2)) { +					if (*src_entry == *dest_entry && (Z_REFCOUNT_PP(dest_entry) % 2)) {  						php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected");  						return 0;  					} @@ -2415,7 +2415,7 @@ ukey:  									Z_ARRVAL_PP(src_entry), recursive TSRMLS_CC))  						return 0;  				} else { -					(*src_entry)->refcount++; +					Z_ADDREF_PP(src_entry);  					zend_u_hash_update(dest, utype, string_key, string_key_len,  									 src_entry, sizeof(zval *), NULL); @@ -2423,7 +2423,7 @@ ukey:  				break;  			case HASH_KEY_IS_LONG: -				(*src_entry)->refcount++; +				Z_ADDREF_PP(src_entry);  				zend_hash_next_index_insert(dest, src_entry, sizeof(zval *), NULL);  				break;  		} @@ -3025,7 +3025,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa  				}  			}  			if (ok) { -				(*((zval**)p->pData))->refcount++; +				Z_ADDREF_PP((zval**)p->pData);  				zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, p->pData, sizeof(zval*), NULL);  			}  		} else { @@ -3039,7 +3039,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa  				}  			}  			if (ok) { -				(*((zval**)p->pData))->refcount++; +				Z_ADDREF_PP((zval**)p->pData);  				zend_u_hash_quick_update(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, p->h, p->pData, sizeof(zval*), NULL);  			}  		} @@ -3458,7 +3458,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty  				}  			}  			if (ok) { -				(*((zval**)p->pData))->refcount++; +				Z_ADDREF_PP((zval**)p->pData);  				zend_hash_index_update(Z_ARRVAL_P(return_value), p->h, p->pData, sizeof(zval*), NULL);  			}  		} else { @@ -3472,7 +3472,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty  				}  			}  			if (ok) { -				(*((zval**)p->pData))->refcount++; +				Z_ADDREF_PP((zval**)p->pData);  				zend_u_hash_quick_update(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, p->h, p->pData, sizeof(zval*), NULL);  			}  		} diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 9516f7027c..4b2d3b9eff 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -5324,7 +5324,7 @@ PHP_FUNCTION(register_shutdown_function)  		}  		for (i = 0; i < shutdown_function_entry.arg_count; i++) { -			shutdown_function_entry.arguments[i]->refcount++; +			Z_ADDREF_P(shutdown_function_entry.arguments[i]);  		}  		zend_hash_next_index_insert(BG(user_shutdown_function_names), &shutdown_function_entry, sizeof(php_shutdown_function_entry), NULL);  	} @@ -5977,7 +5977,7 @@ PHP_FUNCTION(register_tick_function)  	}  	for (i = 0; i < tick_fe.arg_count; i++) { -		tick_fe.arguments[i]->refcount++; +		Z_ADDREF_P(tick_fe.arguments[i]);  	}  	zend_llist_add_element(BG(user_tick_functions), &tick_fe); @@ -6324,7 +6324,7 @@ static int copy_request_variable(void *pDest, int num_args, va_list args, zend_h  	}  	zend_u_delete_global_variable(Z_TYPE(new_key), Z_UNIVAL(new_key), Z_UNILEN(new_key) TSRMLS_CC); -	ZEND_U_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), Z_TYPE(new_key), Z_UNIVAL(new_key), Z_UNILEN(new_key) + 1, *var, (*var)->refcount+1, 0); +	ZEND_U_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), Z_TYPE(new_key), Z_UNIVAL(new_key), Z_UNILEN(new_key) + 1, *var, Z_REFCOUNT_PP(var)+1, 0);  	zval_dtor(&new_key);  	return 0; diff --git a/ext/standard/php_filestat.h b/ext/standard/php_filestat.h index 1062fc7460..0fb9202b8c 100644 --- a/ext/standard/php_filestat.h +++ b/ext/standard/php_filestat.h @@ -62,7 +62,7 @@ PHP_FUNCTION(clearstatcache);  #define MAKE_LONG_ZVAL_INCREF(name, val)\  	MAKE_STD_ZVAL(name); \  	ZVAL_LONG(name, val); \ -	name->refcount++;  +	Z_ADDREF_P(name);   #ifdef PHP_WIN32  #define S_IRUSR S_IREAD diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index c4e132640c..d0af5f75be 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -1201,11 +1201,11 @@ literal:  						zend_uint refcount;  						current = args[objIndex++]; -						refcount = (*current)->refcount; +						refcount = Z_REFCOUNT_PP(current);  						zval_dtor( *current );  						ZVAL_LONG( *current, (long)(string - baseString) ); -						(*current)->refcount = refcount; -						(*current)->is_ref = 1; +						Z_SET_REFCOUNT_PP(current, refcount); +						Z_SET_ISREF_PP(current);  					} else {  						add_index_long(*return_value, objIndex++, string - baseString);  					} @@ -1325,11 +1325,11 @@ literal:  						zend_uint refcount;  						current = args[objIndex++]; -						refcount = (*current)->refcount; +						refcount = Z_REFCOUNT_PP(current);  						zval_dtor( *current );  						ZVAL_STRINGL( *current, string, end-string, 1); -						(*current)->refcount = refcount; -						(*current)->is_ref = 1; +						Z_SET_REFCOUNT_PP(current, refcount); +						Z_SET_ISREF_PP(current);  					} else {  						add_index_stringl( *return_value, objIndex++, string, end-string, 1);  					} @@ -1847,11 +1847,11 @@ literal:  						zend_uint refcount;  						current = args[objIndex++]; -						refcount = (*current)->refcount; +						refcount = Z_REFCOUNT_PP(current);  						zval_dtor( *current );  						ZVAL_LONG( *current, (long)(string - baseString) ); -						(*current)->refcount = refcount; -						(*current)->is_ref = 1; +						Z_SET_REFCOUNT_PP(current, refcount); +						Z_SET_ISREF_PP(current);  					} else {  						add_index_long(*return_value, objIndex++, string - baseString);  					} @@ -1971,11 +1971,11 @@ literal:  						zend_uint refcount;  						current = args[objIndex++]; -						refcount = (*current)->refcount; +						refcount = Z_REFCOUNT_PP(current);  						zval_dtor( *current );  						ZVAL_UNICODEL( *current, string, end-string, 1); -						(*current)->refcount = refcount; -						(*current)->is_ref = 1; +						Z_SET_REFCOUNT_PP(current, refcount); +						Z_SET_ISREF_PP(current);  					} else {  						add_index_unicodel( *return_value, objIndex++, string, end-string, 1);  					} diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 69b3292abb..d30c7b8018 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -967,7 +967,7 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS  		context->notifier = php_stream_notification_alloc();  		context->notifier->func = user_space_stream_notifier;  		context->notifier->ptr = *tmp; -		ZVAL_ADDREF(*tmp); +		Z_ADDREF_P(*tmp);  		context->notifier->dtor = user_space_stream_notifier_dtor;  	}  	if (SUCCESS == zend_ascii_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) { diff --git a/ext/standard/string.c b/ext/standard/string.c index 1a11bb2176..a11dec2afa 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -5666,7 +5666,7 @@ static void php_str_replace_common(INTERNAL_FUNCTION_PARAMETERS, int case_sensit  				php_str_replace_in_subject(search, replace, subject_entry, result, case_sensitivity, (argc > 3) ? &count : NULL TSRMLS_CC);  			} else {  				ALLOC_ZVAL(result); -				ZVAL_ADDREF(*subject_entry); +				Z_ADDREF_P(*subject_entry);  				COPY_PZVAL_TO_ZVAL(*result, *subject_entry);  			}  			/* Add to return array */ diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 27966f748c..c2295c3625 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -336,8 +336,8 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, zva  	/* create the object */  	ALLOC_ZVAL(obj);  	object_init_ex(obj, fdat->ce); -	ZVAL_REFCOUNT(obj) = 1; -	PZVAL_IS_REF(obj) = 1; +	Z_SET_REFCOUNT_P(obj, 1); +	Z_SET_ISREF_P(obj);  	/* filtername */  	add_property_rt_string(obj, "filtername", (char*)filtername, 1); diff --git a/ext/standard/var.c b/ext/standard/var.c index abed4afc2f..3168e3dcbd 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -33,8 +33,7 @@  #include "basic_functions.h"  #include "php_incomplete_class.h" -#define COMMON ((*struc)->is_ref ? "&" : "") -#define Z_REFCOUNT_PP(a) ((*a)->refcount) +#define COMMON (Z_ISREF_PP(struc) ? "&" : "")  /* }}} */ @@ -676,7 +675,7 @@ static inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old  	}  	if (var_old && zend_hash_find(var_hash, p, len, var_old) == SUCCESS) { -		if (!var->is_ref) { +		if (!Z_ISREF_P(var)) {  			/* we still need to bump up the counter, since non-refs will  			   be counted separately by unserializer */  			var_no = -1; @@ -904,7 +903,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var  	if (var_hash   	    && php_add_var_hash(var_hash, struc, (void *) &var_already TSRMLS_CC) == FAILURE) { -		if(struc->is_ref) { +		if(Z_ISREF_P(struc)) {  			smart_str_appendl(buf, "R:", 2);  			smart_str_append_long(buf, *var_already);  			smart_str_appendc(buf, ';'); diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c index a5300878fe..9ca6c54b36 100644 --- a/ext/standard/var_unserializer.c +++ b/ext/standard/var_unserializer.c @@ -76,7 +76,7 @@ static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)  			prev->next = var_hash;  	} -	(*rval)->refcount++; +	Z_ADDREF_PP(rval);  	var_hash->data[var_hash->used_slots++] = *rval;  } @@ -1217,8 +1217,8 @@ yy99:  		zval_ptr_dtor(rval);  	}  	*rval = *rval_ref; -	(*rval)->refcount++; -	(*rval)->is_ref = 0; +	Z_ADDREF_PP(rval); +	Z_UNSET_ISREF_PP(rval);  	return 1;  } @@ -1261,8 +1261,8 @@ yy105:  		zval_ptr_dtor(rval);  	}  	*rval = *rval_ref; -	(*rval)->refcount++; -	(*rval)->is_ref = 1; +	Z_ADDREF_PP(rval); +	Z_SET_ISREF_PP(rval);  	return 1;  } diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re index 0aca9a657a..15daf57261 100644 --- a/ext/standard/var_unserializer.re +++ b/ext/standard/var_unserializer.re @@ -74,7 +74,7 @@ static inline void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)  			prev->next = var_hash;  	} -	(*rval)->refcount++; +	Z_ADDREF_PP(rval);  	var_hash->data[var_hash->used_slots++] = *rval;  } @@ -483,8 +483,8 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)  		zval_ptr_dtor(rval);  	}  	*rval = *rval_ref; -	(*rval)->refcount++; -	(*rval)->is_ref = 1; +	Z_ADDREF_PP(rval); +	Z_SET_ISREF_PP(rval);  	return 1;  } @@ -506,8 +506,8 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER)  		zval_ptr_dtor(rval);  	}  	*rval = *rval_ref; -	(*rval)->refcount++; -	(*rval)->is_ref = 0; +	Z_ADDREF_PP(rval); +	Z_UNSET_ISREF_PP(rval);  	return 1;  } diff --git a/ext/sybase/php_sybase_db.c b/ext/sybase/php_sybase_db.c index a7da813c3e..1da6038f50 100644 --- a/ext/sybase/php_sybase_db.c +++ b/ext/sybase/php_sybase_db.c @@ -1045,7 +1045,7 @@ PHP_FUNCTION(sybase_fetch_row)  	array_init(return_value);  	for (i=0; i<result->num_fields; i++) { -		ZVAL_ADDREF(result->data[result->cur_row][i]); +		Z_ADDREF_P(result->data[result->cur_row][i]);  		zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &result->data[result->cur_row][i], sizeof(zval *), NULL);  	}  	result->cur_row++; @@ -1079,9 +1079,9 @@ static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS)  	array_init(return_value);  	for (i=0; i<result->num_fields; i++) { -		ZVAL_ADDREF(result->data[result->cur_row][i]); +		Z_ADDREF_P(result->data[result->cur_row][i]);  		zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &result->data[result->cur_row][i], sizeof(zval *), NULL); -		ZVAL_ADDREF(result->data[result->cur_row][i]); +		Z_ADDREF_P(result->data[result->cur_row][i]);  		zend_hash_update(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1, (void *) &result->data[result->cur_row][i], sizeof(zval  *), NULL);  	}  	result->cur_row++; diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c index c1d5480c3e..6141ff3080 100644 --- a/ext/sybase_ct/php_sybase_ct.c +++ b/ext/sybase_ct/php_sybase_ct.c @@ -1795,7 +1795,7 @@ static void php_sybase_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int numerics)  		zval_copy_ctor(tmp);  		if (numerics) {  			zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &tmp, sizeof(zval *), NULL); -			tmp->refcount++; +			Z_ADDREF_P(tmp);  		}  		if (zend_hash_exists(Z_ARRVAL_P(return_value), result->fields[i].name, strlen(result->fields[i].name)+1)) { diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 9f0bedaaa4..9d6b2311d5 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -663,8 +663,8 @@ static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)  	Z_TYPE_P(object) = IS_OBJECT;  	object_init_ex(object, pce); -	object->refcount = 1; -	object->is_ref = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	return object;  } diff --git a/ext/unicode/unicode_iterators.c b/ext/unicode/unicode_iterators.c index aaf060bbf3..ef663fb03d 100644 --- a/ext/unicode/unicode_iterators.c +++ b/ext/unicode/unicode_iterators.c @@ -928,7 +928,7 @@ static zend_object_iterator* text_iter_get_iterator(zend_class_entry *ce, zval *  	}  	iter_object = (text_iter_obj *) zend_object_store_get_object(object TSRMLS_CC); -	ZVAL_ADDREF(object); +	Z_ADDREF_P(object);  	iter_object->iter.data  = (void *) object;  	iter_object->iter.funcs = &text_iter_funcs; diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 1954b37164..34d475a8d6 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -971,7 +971,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)  						zend_class_entry *old_scope = EG(scope);  		    				EG(scope) = Z_OBJCE_P(ent2->data); -						ent1->data->refcount--; +						Z_DELREF_P(ent1->data);  						add_property_zval(ent2->data, ent1->varname, ent1->data);  						EG(scope) = old_scope;  					} else { diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index 0257ea5b5b..2d73b8a00f 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -172,7 +172,7 @@ zval *xmlreader_read_property(zval *object, zval *member, int type TSRMLS_DC)  		ret = xmlreader_property_reader(obj, hnd, &retval TSRMLS_CC);  		if (ret == SUCCESS) {  			/* ensure we're creating a temporary variable */ -			retval->refcount = 0; +			Z_SET_REFCOUNT_P(retval, 0);  		} else {  			retval = EG(uninitialized_zval_ptr);  		} diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 01c3a0201b..3fb9f3dd96 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -700,7 +700,7 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)  			convert_to_string_with_converter(*entry, UG(utf8_conv));  			ALLOC_ZVAL(new_string); -			ZVAL_ADDREF(*entry); +			Z_ADDREF_P(*entry);  			COPY_PZVAL_TO_ZVAL(*new_string, *entry);  			zend_hash_update(intern->parameter, string_key.s, tmp_len, &new_string, sizeof(zval*), NULL); diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index e443e16035..d2a71e5cdb 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -433,7 +433,7 @@ static zval* php_zip_read_property(zval *object, zval *member, int type TSRMLS_D  		ret = php_zip_property_reader(obj, hnd, &retval, 1 TSRMLS_CC);  		if (ret == SUCCESS) {  			/* ensure we're creating a temporary variable */ -			retval->refcount = 0; +			Z_SET_REFCOUNT_P(retval, 0);  		} else {  			retval = EG(uninitialized_zval_ptr);  		} @@ -477,8 +477,8 @@ static int php_zip_has_property(zval *object, zval *member, int type TSRMLS_DC)  		if (type == 2) {  			retval = 1;  		} else if (php_zip_property_reader(obj, hnd, &tmp, 1 TSRMLS_CC) == SUCCESS) { -			tmp->refcount = 1; -			tmp->is_ref = 0; +			Z_SET_REFCOUNT_P(tmp, 1); +			Z_UNSET_ISREF_P(tmp);  			if (type == 1) {  				retval = zend_is_true(tmp);  			} else if (type == 0) { diff --git a/main/output.c b/main/output.c index f3aac67ca6..5b2c05816f 100644 --- a/main/output.c +++ b/main/output.c @@ -539,7 +539,7 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler,  			MAKE_STD_ZVAL(handler_name);  			if (SUCCESS == zend_fcall_info_init(output_handler, &user->fci, &user->fcc, handler_name TSRMLS_CC)) {  				handler = php_output_handler_init(handler_name, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER); -				ZVAL_ADDREF(output_handler); +				Z_ADDREF_P(output_handler);  				user->zoh = output_handler;  				handler->func.user = user;  			} else { @@ -889,7 +889,7 @@ static inline php_output_handler *php_output_handler_init_ex(zval *name, size_t  	php_output_handler *handler;  	handler = ecalloc(1, sizeof(php_output_handler)); -	ZVAL_ADDREF(name); +	Z_ADDREF_P(name);  	handler->name = name;  	handler->size = chunk_size;  	handler->flags = flags; @@ -1188,7 +1188,7 @@ static int php_output_stack_apply_list(void *h, void *z)  	php_output_handler *handler = *(php_output_handler **) h;  	zval *array = (zval *) z; -	ZVAL_ADDREF(handler->name); +	Z_ADDREF_P(handler->name);  	add_next_index_zval(array, handler->name);  	return 0;  } @@ -1216,7 +1216,7 @@ static inline zval *php_output_handler_status(php_output_handler *handler, zval  		array_init(entry);  	} -	ZVAL_ADDREF(handler->name); +	Z_ADDREF_P(handler->name);  	add_ascii_assoc_zval(entry, "name", handler->name);  	add_ascii_assoc_long(entry, "type", (long) (handler->flags & 0xf));  	add_ascii_assoc_long(entry, "flags", (long) handler->flags); diff --git a/main/php_ini.c b/main/php_ini.c index a5afcee884..0b6edf8bcd 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -207,7 +207,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t  					copy = *arg2;  					zval_copy_ctor(©); -					copy.refcount = 0; +					Z_SET_REFCOUNT(copy, 0);  					zend_llist_add_element(&extension_lists.functions, ©);  				} else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */  					char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); @@ -569,7 +569,7 @@ int php_init_config(TSRMLS_D)  			Z_STRLEN(tmp) = strlen(fh.filename);  			Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));  			Z_TYPE(tmp) = IS_STRING; -			tmp.refcount = 0; +			Z_SET_REFCOUNT(tmp, 0);  			zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL);  			if (php_ini_opened_path) { diff --git a/main/php_streams.h b/main/php_streams.h index 94ec452e60..d7f3e6c34b 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -414,15 +414,15 @@ static inline int _php_stream_path_param_encode(zval **ppzval, char **ppath, int  		}  		MAKE_STD_ZVAL(zpath);  		ZVAL_STRINGL(zpath, path, path_len, 0); -		zpath->is_ref = 0; -		zpath->refcount = 1; +		Z_UNSET_ISREF_P(zpath); +		Z_SET_REFCOUNT_P(zpath, 1);  		/* Replace the param stack with the new zval */  		zval_ptr_dtor(ppzval);  		*ppzval = zpath;  	} else if (Z_TYPE_PP(ppzval) != IS_STRING) { -		if ((*ppzval)->is_ref || -			(*ppzval)->refcount > 1) { +		if (Z_ISREF_PP(ppzval) || +			Z_REFCOUNT_PP(ppzval) > 1) {  			zval *zpath;  			/* Produce a new zval of type string */ @@ -430,8 +430,8 @@ static inline int _php_stream_path_param_encode(zval **ppzval, char **ppath, int  			*zpath = **ppzval;  			zval_copy_ctor(zpath);  			convert_to_string(zpath); -			zpath->is_ref = 0; -			zpath->refcount = 1; +			Z_UNSET_ISREF_P(zpath); +			Z_SET_REFCOUNT_P(zpath, 1);  			/* Replace the param stack with it */  			zval_ptr_dtor(ppzval); diff --git a/main/php_variables.c b/main/php_variables.c index 7fbe3d4779..91d1381f11 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -734,14 +734,14 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)  	Z_TYPE_P(argc) = IS_LONG;  	if (SG(request_info).argc) { -		arr->refcount++; -		argc->refcount++; +		Z_ADDREF_P(arr); +		Z_ADDREF_P(argc);  		zend_ascii_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);  		zend_ascii_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);  	}   	if (track_vars_array) { -		arr->refcount++; -		argc->refcount++; +		Z_ADDREF_P(arr); +		Z_ADDREF_P(argc);  		zend_ascii_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);  		zend_ascii_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);  	} @@ -824,7 +824,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)  			|| (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS)  			|| Z_TYPE_PP(dest_entry) != IS_ARRAY          ) { -			(*src_entry)->refcount++; +			Z_ADDREF_PP(src_entry);  			if (key_type == HASH_KEY_IS_STRING || key_type == HASH_KEY_IS_UNICODE) {  				zend_u_hash_update(dest, key_type, string_key, string_key_len, src_entry, sizeof(zval *), NULL);  			} else { @@ -927,7 +927,7 @@ int php_hash_environment(TSRMLS_D)  			INIT_PZVAL(PG(http_globals)[i]);  		} -		PG(http_globals)[i]->refcount++; +		Z_ADDREF_P(PG(http_globals)[i]);  		zend_ascii_hash_update(&EG(symbol_table), auto_global_records[i].name, auto_global_records[i].name_len, &PG(http_globals)[i], sizeof(zval *), NULL);  	} @@ -952,8 +952,8 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS  				if (zend_ascii_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS &&  				    zend_ascii_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) { -					(*argc)->refcount++; -					(*argv)->refcount++; +					Z_ADDREF_PP(argc); +					Z_ADDREF_PP(argv);  					zend_ascii_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL);  					zend_ascii_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), argc, sizeof(zval *), NULL);  				} @@ -974,7 +974,7 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS  	}  	zend_ascii_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); -	PG(http_globals)[TRACK_VARS_SERVER]->refcount++; +	Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);  	return 0; /* don't rearm */  } @@ -995,7 +995,7 @@ static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC  	}  	zend_ascii_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL); -	PG(http_globals)[TRACK_VARS_ENV]->refcount++; +	Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);  	return 0; /* don't rearm */  } diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h index afe0695398..409c7187a1 100644 --- a/main/streams/php_stream_filter_api.h +++ b/main/streams/php_stream_filter_api.h @@ -73,7 +73,7 @@ PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, s  PHPAPI php_stream_bucket *php_stream_bucket_new_unicode(php_stream *stream, UChar *buf, int32_t buflen, int own_buf, int buf_persistent TSRMLS_DC);  PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length TSRMLS_DC);  PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket TSRMLS_DC); -#define php_stream_bucket_addref(bucket)	(bucket)->refcount++ +#define php_stream_bucket_addref(bucket)	Z_ADDREF_P((bucket))  PHPAPI void php_stream_bucket_prepend(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket TSRMLS_DC);  PHPAPI void php_stream_bucket_append(php_stream_bucket_brigade *brigade, php_stream_bucket *bucket TSRMLS_DC);  PHPAPI void php_stream_bucket_unlink(php_stream_bucket *bucket TSRMLS_DC); diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 0022b44e07..279c3f38b3 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -242,8 +242,8 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena  	/* create an instance of our class */  	ALLOC_ZVAL(us->object);  	object_init_ex(us->object, uwrap->ce); -	ZVAL_REFCOUNT(us->object) = 1; -	PZVAL_IS_REF(us->object) = 1; +	Z_SET_REFCOUNT_P(us->object, 1); +	Z_SET_ISREF_P(us->object);  	if (uwrap->ce->constructor) {  		zend_fcall_info fci; @@ -305,8 +305,8 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena  	args[2] = &zoptions;  	MAKE_STD_ZVAL(zopened); -	ZVAL_REFCOUNT(zopened) = 1; -	PZVAL_IS_REF(zopened) = 1; +	Z_SET_REFCOUNT_P(zopened, 1); +	Z_SET_ISREF_P(zopened);  	ZVAL_NULL(zopened);  	args[3] = &zopened; @@ -380,8 +380,8 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, char *filen  	/* create an instance of our class */  	ALLOC_ZVAL(us->object);  	object_init_ex(us->object, uwrap->ce); -	ZVAL_REFCOUNT(us->object) = 1; -	PZVAL_IS_REF(us->object) = 1; +	Z_SET_REFCOUNT_P(us->object, 1); +	Z_SET_ISREF_P(us->object);  	if (context) {  		MAKE_STD_ZVAL(zcontext); @@ -961,8 +961,8 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio  	/* create an instance of our class */  	ALLOC_ZVAL(object);  	object_init_ex(object, uwrap->ce); -	ZVAL_REFCOUNT(object) = 1; -	PZVAL_IS_REF(object) = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	if (context) {  		MAKE_STD_ZVAL(zcontext); @@ -1019,8 +1019,8 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char  	/* create an instance of our class */  	ALLOC_ZVAL(object);  	object_init_ex(object, uwrap->ce); -	ZVAL_REFCOUNT(object) = 1; -	PZVAL_IS_REF(object) = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	if (context) {  		MAKE_STD_ZVAL(zcontext); @@ -1082,8 +1082,8 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, char *url, int mode,  	/* create an instance of our class */  	ALLOC_ZVAL(object);  	object_init_ex(object, uwrap->ce); -	ZVAL_REFCOUNT(object) = 1; -	PZVAL_IS_REF(object) = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	if (context) {  		MAKE_STD_ZVAL(zcontext); @@ -1151,8 +1151,8 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int option  	/* create an instance of our class */  	ALLOC_ZVAL(object);  	object_init_ex(object, uwrap->ce); -	ZVAL_REFCOUNT(object) = 1; -	PZVAL_IS_REF(object) = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	if (context) {  		MAKE_STD_ZVAL(zcontext); @@ -1215,8 +1215,8 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, int fla  	/* create an instance of our class */  	ALLOC_ZVAL(object);  	object_init_ex(object, uwrap->ce); -	ZVAL_REFCOUNT(object) = 1; -	PZVAL_IS_REF(object) = 1; +	Z_SET_REFCOUNT_P(object, 1); +	Z_SET_ISREF_P(object);  	if (context) {  		MAKE_STD_ZVAL(zcontext); diff --git a/win32/registry.c b/win32/registry.c index cdeb85f21d..d5f84af595 100644 --- a/win32/registry.c +++ b/win32/registry.c @@ -102,7 +102,7 @@ static int LoadDirectory(HashTable *directories, HKEY key, char *path, int path_  					     zend_hash_get_current_key_ex(parent_ht, &index, &index_len, &num, 0, &pos) == HASH_KEY_IS_STRING;  					     zend_hash_move_forward_ex(parent_ht, &pos)) {  						if (zend_hash_add(ht, index, index_len, data, sizeof(zval*), NULL) == SUCCESS) { -						    (*data)->refcount++; +						    Z_ADDREF_PP(data);  						}  					}  				}  | 
