]> granicus.if.org Git - php/commitdiff
Use better data structures (incomplete)
authorDmitry Stogov <dmitry@zend.com>
Tue, 18 Feb 2014 13:31:27 +0000 (17:31 +0400)
committerDmitry Stogov <dmitry@zend.com>
Tue, 18 Feb 2014 13:31:27 +0000 (17:31 +0400)
Zend/zend.h
Zend/zend_builtin_functions.c
Zend/zend_execute_API.c

index 4d212c5e1f889c4c3796bdcd8f2d1ec7ada6fd5a..44266c29ce83c6085a0327008b92a63454498410 100644 (file)
@@ -711,9 +711,11 @@ END_EXTERN_C()
 
 #define COPY_PZVAL_TO_ZVAL(zv, pzv)                    \
        ZVAL_COPY_VALUE(&(zv), (pzv));                  \
-       if (Z_REFCOUNT_P(pzv)>1) {                              \
-               zval_copy_ctor(&(zv));                          \
-               Z_DELREF_P((pzv));                                      \
+       if (IS_REFCOUNTED(Z_TYPE_P(pzv))) {             \
+               if (Z_REFCOUNT_P(pzv)>1) {                      \
+                       zval_copy_ctor(&(zv));                  \
+                       Z_DELREF_P((pzv));                              \
+               }                                                                       \
        }                                                                               \
 
 #define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
index 5e7669e746301db1706e157a399c349e507ca1d8..b354fa777fe57da8af27eb798c6da0ec5659c550 100644 (file)
@@ -468,7 +468,7 @@ ZEND_FUNCTION(func_get_args)
                arg = p-(arg_count-i);
                if (!Z_ISREF_P(arg)) {
                        element = arg;
-                       Z_ADDREF_P(element);
+                       if (IS_REFCOUNTED(Z_TYPE_P(element))) Z_ADDREF_P(element);
                } else {
                        ZVAL_DUP(&tmp, Z_REFVAL_P(arg));
                        element = &tmp;
index 509e6b8ed68cdb8edf93b4ff825435317ea44807..21958308a09d006ee9d4d8d0aede1f8f0cbaa30b 100644 (file)
@@ -738,7 +738,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
        zend_fcall_info_cache fci_cache_local;
        zval tmp;
 
-       fci->retval = NULL;
+       ZVAL_UNDEF(fci->retval);
 
        if (!EG(active)) {
                return FAILURE; /* executor is already inactive */
@@ -802,7 +802,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
        calling_scope = fci_cache->calling_scope;
        called_scope = fci_cache->called_scope;
        fci->object_ptr = fci_cache->object_ptr;
-       ZVAL_COPY_VALUE(&EX(object), fci->object_ptr);
+       if (fci->object_ptr) {
+               ZVAL_COPY_VALUE(&EX(object), fci->object_ptr);
+       } else {
+               ZVAL_UNDEF(&EX(object));
+       }
        if (fci->object_ptr && Z_TYPE_P(fci->object_ptr) == IS_OBJECT &&
            (!EG(objects_store).object_buckets ||
             !IS_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(fci->object_ptr)]))) {
@@ -859,12 +863,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
                           (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) {
                        param = &tmp;
                        ZVAL_DUP(param, &fci->params[i]);
-//???          } else if (*fci->params[i] != &EG(uninitialized_zval)) {
-                       Z_ADDREF(fci->params[i]);
-                       param = &fci->params[i];
-//???          } else {
-//???                  param = &tmp;
-//???                  ZVAL_COPY_VALUE(param, &fci->params[i]);
+               } else {
+                       param = &tmp;
+                       ZVAL_COPY(param, &fci->params[i]);
                }
                zend_vm_stack_push(param TSRMLS_CC);
        }