PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_variables.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 48 63 76.2 %
Date: 2016-07-26 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    |          Dmitry Stogov <dmitry@zend.com>                             |
      18             :    +----------------------------------------------------------------------+
      19             : */
      20             : 
      21             : /* $Id$ */
      22             : 
      23             : #include <stdio.h>
      24             : #include "zend.h"
      25             : #include "zend_API.h"
      26             : #include "zend_ast.h"
      27             : #include "zend_globals.h"
      28             : #include "zend_constants.h"
      29             : #include "zend_list.h"
      30             : 
      31    30987348 : ZEND_API void ZEND_FASTCALL _zval_dtor_func(zend_refcounted *p ZEND_FILE_LINE_DC)
      32             : {
      33    30987348 :         switch (GC_TYPE(p)) {
      34             :                 case IS_STRING:
      35             :                 case IS_CONSTANT: {
      36    17829754 :                                 zend_string *str = (zend_string*)p;
      37             :                                 CHECK_ZVAL_STRING_REL(str);
      38             :                                 zend_string_free(str);
      39    17829754 :                                 break;
      40             :                         }
      41             :                 case IS_ARRAY: {
      42     4027887 :                                 zend_array *arr = (zend_array*)p;
      43     4027887 :                                 zend_array_destroy(arr);
      44     4027886 :                                 break;
      45             :                         }
      46             :                 case IS_CONSTANT_AST: {
      47         124 :                                 zend_ast_ref *ast = (zend_ast_ref*)p;
      48             : 
      49         124 :                                 zend_ast_destroy_and_free(ast->ast);
      50         124 :                                 efree_size(ast, sizeof(zend_ast_ref));
      51         124 :                                 break;
      52             :                         }
      53             :                 case IS_OBJECT: {
      54     2305010 :                                 zend_object *obj = (zend_object*)p;
      55             : 
      56     2305010 :                                 zend_objects_store_del(obj);
      57     2305007 :                                 break;
      58             :                         }
      59             :                 case IS_RESOURCE: {
      60      551651 :                                 zend_resource *res = (zend_resource*)p;
      61             : 
      62             :                                 /* destroy resource */
      63      551651 :                                 zend_list_free(res);
      64      551651 :                                 break;
      65             :                         }
      66             :                 case IS_REFERENCE: {
      67     6014633 :                                 zend_reference *ref = (zend_reference*)p;
      68             : 
      69     6014633 :                                 i_zval_ptr_dtor(&ref->val ZEND_FILE_LINE_RELAY_CC);
      70     6014633 :                                 efree_size(ref, sizeof(zend_reference));
      71             :                                 break;
      72             :                         }
      73             :                 default:
      74             :                         break;
      75             :         }
      76    30987344 : }
      77             : 
      78    60602124 : ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
      79             : {
      80    60602124 :         switch (Z_TYPE_P(zvalue)) {
      81             :                 case IS_STRING:
      82             :                 case IS_CONSTANT:
      83             :                         CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
      84     2231518 :                         zend_string_release(Z_STR_P(zvalue));
      85     2231518 :                         break;
      86             :                 case IS_ARRAY:
      87             :                 case IS_CONSTANT_AST:
      88             :                 case IS_OBJECT:
      89             :                 case IS_RESOURCE:
      90           0 :                         zend_error_noreturn(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
      91             :                         break;
      92             :                 case IS_REFERENCE: {
      93           0 :                                 zend_reference *ref = (zend_reference*)Z_REF_P(zvalue);
      94             : 
      95           0 :                                 zval_internal_ptr_dtor(&ref->val);
      96           0 :                                 free(ref);
      97             :                                 break;
      98             :                         }
      99             :                 case IS_LONG:
     100             :                 case IS_DOUBLE:
     101             :                 case IS_FALSE:
     102             :                 case IS_TRUE:
     103             :                 case IS_NULL:
     104             :                 default:
     105             :                         break;
     106             :         }
     107    60602124 : }
     108             : 
     109     1010027 : ZEND_API void _zval_internal_dtor_for_ptr(zval *zvalue ZEND_FILE_LINE_DC)
     110             : {
     111     1010027 :         switch (Z_TYPE_P(zvalue)) {
     112             :                 case IS_STRING:
     113             :                 case IS_CONSTANT:
     114             :                         CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
     115     1010027 :                         zend_string_free(Z_STR_P(zvalue));
     116     1010027 :                         break;
     117             :                 case IS_ARRAY:
     118             :                 case IS_CONSTANT_AST:
     119             :                 case IS_OBJECT:
     120             :                 case IS_RESOURCE:
     121           0 :                         zend_error_noreturn(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
     122             :                         break;
     123             :                 case IS_REFERENCE: {
     124           0 :                                 zend_reference *ref = (zend_reference*)Z_REF_P(zvalue);
     125             : 
     126           0 :                                 zval_internal_ptr_dtor(&ref->val);
     127           0 :                                 free(ref);
     128             :                                 break;
     129             :                         }
     130             :                 case IS_LONG:
     131             :                 case IS_DOUBLE:
     132             :                 case IS_FALSE:
     133             :                 case IS_TRUE:
     134             :                 case IS_NULL:
     135             :                 default:
     136             :                         break;
     137             :         }
     138     1010027 : }
     139             : 
     140             : /* This function should only be used as a copy constructor, i.e. it
     141             :  * should only be called AFTER a zval has been copied to another
     142             :  * location using ZVAL_COPY_VALUE. Do not call it before copying,
     143             :  * otherwise a reference may be leaked. */
     144      839347 : ZEND_API void zval_add_ref(zval *p)
     145             : {
     146      839347 :         if (Z_REFCOUNTED_P(p)) {
     147      836692 :                 if (Z_ISREF_P(p) && Z_REFCOUNT_P(p) == 1) {
     148           5 :                         ZVAL_COPY(p, Z_REFVAL_P(p));
     149             :                 } else {
     150             :                         Z_ADDREF_P(p);
     151             :                 }
     152             :         }
     153      839347 : }
     154             : 
     155           0 : ZEND_API void zval_add_ref_unref(zval *p)
     156             : {
     157           0 :         if (Z_REFCOUNTED_P(p)) {
     158           0 :                 if (Z_ISREF_P(p)) {
     159           0 :                         ZVAL_COPY(p, Z_REFVAL_P(p));
     160             :                 } else {
     161             :                         Z_ADDREF_P(p);
     162             :                 }
     163             :         }
     164           0 : }
     165             : 
     166     1172353 : ZEND_API void ZEND_FASTCALL _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
     167             : {
     168     1172353 :         if (EXPECTED(Z_TYPE_P(zvalue) == IS_ARRAY)) {
     169     1013820 :                 ZVAL_ARR(zvalue, zend_array_dup(Z_ARRVAL_P(zvalue)));
     170      317074 :         } else if (EXPECTED(Z_TYPE_P(zvalue) == IS_STRING) ||
     171          11 :                    EXPECTED(Z_TYPE_P(zvalue) == IS_CONSTANT)) {
     172             :                 CHECK_ZVAL_STRING_REL(Z_STR_P(zvalue));
     173      317060 :                 Z_STR_P(zvalue) = zend_string_dup(Z_STR_P(zvalue), 0);
     174           3 :         } else if (EXPECTED(Z_TYPE_P(zvalue) == IS_CONSTANT_AST)) {
     175           3 :                 zend_ast *copy = zend_ast_copy(Z_ASTVAL_P(zvalue));
     176           3 :                 ZVAL_NEW_AST(zvalue, copy);
     177             :         }
     178     1172353 : }
     179             : 
     180             : 
     181        1321 : ZEND_API size_t zend_print_variable(zval *var)
     182             : {
     183        1321 :         return zend_print_zval(var, 0);
     184             : }
     185             : 
     186             : 
     187           0 : ZEND_API void _zval_dtor_wrapper(zval *zvalue)
     188             : {
     189             :         zval_dtor(zvalue);
     190           0 : }
     191             : 
     192             : 
     193             : #if ZEND_DEBUG
     194             : ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
     195             : {
     196             :         zval_internal_dtor(zvalue);
     197             : }
     198             : 
     199             : 
     200             : ZEND_API void _zval_ptr_dtor_wrapper(zval *zval_ptr)
     201             : {
     202             : 
     203             :         i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_CC);
     204             : }
     205             : 
     206             : 
     207             : ZEND_API void _zval_internal_ptr_dtor_wrapper(zval *zval_ptr)
     208             : {
     209             :         zval_internal_ptr_dtor(zval_ptr);
     210             : }
     211             : #endif
     212             : 
     213             : /*
     214             :  * Local variables:
     215             :  * tab-width: 4
     216             :  * c-basic-offset: 4
     217             :  * indent-tabs-mode: t
     218             :  * End:
     219             :  */

Generated by: LCOV version 1.10

Generated at Tue, 26 Jul 2016 17:07:27 +0000 (14 hours ago)

Copyright © 2005-2016 The PHP Group
All rights reserved.