summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2010-07-16 13:38:09 +0000
committerDmitry Stogov <dmitry@php.net>2010-07-16 13:38:09 +0000
commitca4de03eed5b6e072fc5ec80a5dbbfe6c96dca8d (patch)
tree0419ff8d128d6508bd5c4025df63713a28f1f5b9 /Zend/zend_execute.c
parent8aad91d14a0d213b1eb6fc1c3160f05c1faee228 (diff)
downloadphp-git-ca4de03eed5b6e072fc5ec80a5dbbfe6c96dca8d.tar.gz
ZEND_FETCH_*_R operations simplified and can't be used with EXT_TYPE_UNUSED flag any more. Thit is very rare and useless case. ZEND_FREE might be required after them instead.
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r--Zend/zend_execute.c66
1 files changed, 24 insertions, 42 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index d6d6a33ded..b71196ecb1 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1218,23 +1218,18 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval **cont
case IS_ARRAY:
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC);
- if (result) {
- AI_SET_PTR(result, *retval);
- PZVAL_LOCK(*retval);
- }
+ AI_SET_PTR(result, *retval);
+ PZVAL_LOCK(*retval);
return;
- break;
case IS_NULL:
- if (result) {
- AI_SET_PTR(result, &EG(uninitialized_zval));
- PZVAL_LOCK(&EG(uninitialized_zval));
- }
+ AI_SET_PTR(result, &EG(uninitialized_zval));
+ PZVAL_LOCK(&EG(uninitialized_zval));
return;
- break;
case IS_STRING: {
zval tmp;
+ zval *ptr;
if (Z_TYPE_P(dim) != IS_LONG) {
switch(Z_TYPE_P(dim)) {
@@ -1255,25 +1250,22 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval **cont
convert_to_long(&tmp);
dim = &tmp;
}
- if (result) {
- zval *ptr;
-
- ALLOC_ZVAL(ptr);
- INIT_PZVAL(ptr);
- Z_TYPE_P(ptr) = IS_STRING;
-
- if (Z_LVAL_P(dim) < 0 || Z_STRLEN_P(container) <= Z_LVAL_P(dim)) {
- zend_error(E_NOTICE, "Uninitialized string offset: %ld", Z_LVAL_P(dim));
- Z_STRVAL_P(ptr) = STR_EMPTY_ALLOC();
- Z_STRLEN_P(ptr) = 0;
- } else {
- Z_STRVAL_P(ptr) = (char*)emalloc(2);
- Z_STRVAL_P(ptr)[0] = Z_STRVAL_P(container)[Z_LVAL_P(dim)];
- Z_STRVAL_P(ptr)[1] = 0;
- Z_STRLEN_P(ptr) = 1;
- }
- AI_SET_PTR(result, ptr);
+
+ ALLOC_ZVAL(ptr);
+ INIT_PZVAL(ptr);
+ Z_TYPE_P(ptr) = IS_STRING;
+
+ if (Z_LVAL_P(dim) < 0 || Z_STRLEN_P(container) <= Z_LVAL_P(dim)) {
+ zend_error(E_NOTICE, "Uninitialized string offset: %ld", Z_LVAL_P(dim));
+ Z_STRVAL_P(ptr) = STR_EMPTY_ALLOC();
+ Z_STRLEN_P(ptr) = 0;
+ } else {
+ Z_STRVAL_P(ptr) = (char*)emalloc(2);
+ Z_STRVAL_P(ptr)[0] = Z_STRVAL_P(container)[Z_LVAL_P(dim)];
+ Z_STRVAL_P(ptr)[1] = 0;
+ Z_STRLEN_P(ptr) = 1;
}
+ AI_SET_PTR(result, ptr);
return;
}
break;
@@ -1292,14 +1284,8 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval **cont
overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC);
if (overloaded_result) {
- if (result) {
- AI_SET_PTR(result, overloaded_result);
- PZVAL_LOCK(overloaded_result);
- } else if (Z_REFCOUNT_P(overloaded_result) == 0) {
- /* Destroy unused result from offsetGet() magic method */
- Z_SET_REFCOUNT_P(overloaded_result, 1);
- zval_ptr_dtor(&overloaded_result);
- }
+ AI_SET_PTR(result, overloaded_result);
+ PZVAL_LOCK(overloaded_result);
} else if (result) {
AI_SET_PTR(result, &EG(uninitialized_zval));
PZVAL_LOCK(&EG(uninitialized_zval));
@@ -1309,15 +1295,11 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval **cont
}
}
return;
- break;
default:
- if (result) {
- AI_SET_PTR(result, &EG(uninitialized_zval));
- PZVAL_LOCK(&EG(uninitialized_zval));
- }
+ AI_SET_PTR(result, &EG(uninitialized_zval));
+ PZVAL_LOCK(&EG(uninitialized_zval));
return;
- break;
}
}