diff options
author | Yiduo (David) Wang <davidw@php.net> | 2007-10-07 05:15:07 +0000 |
---|---|---|
committer | Yiduo (David) Wang <davidw@php.net> | 2007-10-07 05:15:07 +0000 |
commit | 95da0dc5700ee9d41f1e5664c8167cd37023dbd3 (patch) | |
tree | e4c6288af1a3f260bbd705c83c397741233d60ea /Zend/zend_execute_API.c | |
parent | d20f6ecac8e2db5b0595c4fdef4cae221594ab88 (diff) | |
download | php-git-95da0dc5700ee9d41f1e5664c8167cd37023dbd3.tar.gz |
Added macros for managing zval refcounts and is_ref statuses
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 60 |
1 files changed, 30 insertions, 30 deletions
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: |