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: 71 73 97.3 %
Date: 2014-10-24 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 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             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #include <stdio.h>
      23             : #include "zend.h"
      24             : #include "zend_API.h"
      25             : #include "zend_globals.h"
      26             : #include "zend_constants.h"
      27             : #include "zend_list.h"
      28             : 
      29             : 
      30    28460861 : ZEND_API void _zval_dtor_func(zval *zvalue ZEND_FILE_LINE_DC)
      31             : {
      32    28460861 :         switch (Z_TYPE_P(zvalue) & IS_CONSTANT_TYPE_MASK) {
      33             :                 case IS_STRING:
      34             :                 case IS_CONSTANT:
      35             :                         CHECK_ZVAL_STRING_REL(zvalue);
      36    22133341 :                         STR_FREE_REL(zvalue->value.str.val);
      37    22133341 :                         break;
      38             :                 case IS_ARRAY:
      39             :                 case IS_CONSTANT_ARRAY: {
      40             :                                 TSRMLS_FETCH();
      41             : 
      42     3679219 :                                 if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
      43             :                                         /* break possible cycles */
      44     3676016 :                                         Z_TYPE_P(zvalue) = IS_NULL;
      45     3676016 :                                         zend_hash_destroy(zvalue->value.ht);
      46     3676014 :                                         FREE_HASHTABLE(zvalue->value.ht);
      47             :                                 }
      48             :                         }
      49     3679217 :                         break;
      50             :                 case IS_OBJECT:
      51             :                         {
      52             :                                 TSRMLS_FETCH();
      53             : 
      54     2046110 :                                 Z_OBJ_HT_P(zvalue)->del_ref(zvalue TSRMLS_CC);
      55             :                         }
      56     2046103 :                         break;
      57             :                 case IS_RESOURCE:
      58             :                         {
      59             :                                 TSRMLS_FETCH();
      60             : 
      61             :                                 /* destroy resource */
      62      602103 :                                 zend_list_delete(zvalue->value.lval);
      63             :                         }
      64      602103 :                         break;
      65             :                 case IS_LONG:
      66             :                 case IS_DOUBLE:
      67             :                 case IS_BOOL:
      68             :                 case IS_NULL:
      69             :                 default:
      70          88 :                         return;
      71             :                         break;
      72             :         }
      73             : }
      74             : 
      75             : 
      76     9948151 : ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
      77             : {
      78     9948151 :         switch (Z_TYPE_P(zvalue) & IS_CONSTANT_TYPE_MASK) {
      79             :                 case IS_STRING:
      80             :                 case IS_CONSTANT:
      81             :                         CHECK_ZVAL_STRING_REL(zvalue);
      82      688874 :                         str_free(zvalue->value.str.val);
      83      688874 :                         break;
      84             :                 case IS_ARRAY:
      85             :                 case IS_CONSTANT_ARRAY:
      86             :                 case IS_OBJECT:
      87             :                 case IS_RESOURCE:
      88           0 :                         zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
      89             :                         break;
      90             :                 case IS_LONG:
      91             :                 case IS_DOUBLE:
      92             :                 case IS_BOOL:
      93             :                 case IS_NULL:
      94             :                 default:
      95             :                         break;
      96             :         }
      97     9948151 : }
      98             : 
      99             : 
     100     7038180 : ZEND_API void zval_add_ref(zval **p)
     101             : {
     102     7038180 :         Z_ADDREF_PP(p);
     103     7038180 : }
     104             : 
     105             : 
     106     8213188 : ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
     107             : {
     108     8213188 :         switch (Z_TYPE_P(zvalue) & IS_CONSTANT_TYPE_MASK) {
     109             :                 case IS_RESOURCE: {
     110             :                                 TSRMLS_FETCH();
     111             : 
     112        1857 :                                 zend_list_addref(zvalue->value.lval);
     113             :                         }
     114        1857 :                         break;
     115             :                 case IS_BOOL:
     116             :                 case IS_LONG:
     117             :                 case IS_NULL:
     118           0 :                         break;
     119             :                 case IS_CONSTANT:
     120             :                 case IS_STRING:
     121             :                         CHECK_ZVAL_STRING_REL(zvalue);
     122     6819122 :                         if (!IS_INTERNED(zvalue->value.str.val)) {
     123      805115 :                                 zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len);
     124             :                         }
     125     6819122 :                         break;
     126             :                 case IS_ARRAY:
     127             :                 case IS_CONSTANT_ARRAY: {
     128             :                                 zval *tmp;
     129     1012051 :                                 HashTable *original_ht = zvalue->value.ht;
     130     1012051 :                                 HashTable *tmp_ht = NULL;
     131             :                                 TSRMLS_FETCH();
     132             : 
     133     1012051 :                                 if (zvalue->value.ht == &EG(symbol_table)) {
     134        2994 :                                         return; /* do nothing */
     135             :                                 }
     136     1009057 :                                 ALLOC_HASHTABLE_REL(tmp_ht);
     137     1009057 :                                 zend_hash_init(tmp_ht, zend_hash_num_elements(original_ht), NULL, ZVAL_PTR_DTOR, 0);
     138     1009057 :                                 zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
     139     1009057 :                                 zvalue->value.ht = tmp_ht;
     140             :                         }
     141     1009057 :                         break;
     142             :                 case IS_OBJECT:
     143             :                         {
     144             :                                 TSRMLS_FETCH();
     145      380158 :                                 Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);
     146             :                         }
     147             :                         break;
     148             :         }
     149             : }
     150             : 
     151             : 
     152      228949 : ZEND_API int zend_print_variable(zval *var) 
     153             : {
     154      228949 :         return zend_print_zval(var, 0);
     155             : }
     156             : 
     157             : 
     158           4 : ZEND_API void _zval_dtor_wrapper(zval *zvalue)
     159             : {
     160             :         TSRMLS_FETCH();
     161             : 
     162           4 :         GC_REMOVE_ZVAL_FROM_BUFFER(zvalue);
     163             :         zval_dtor(zvalue);
     164           4 : }
     165             : 
     166             : 
     167             : #if ZEND_DEBUG
     168             : ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
     169             : {
     170             :         zval_copy_ctor(zvalue);
     171             : }
     172             : 
     173             : 
     174             : ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
     175             : {
     176             :         zval_internal_dtor(zvalue);
     177             : }
     178             : 
     179             : 
     180             : ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr)
     181             : {
     182             :         zval_ptr_dtor(zval_ptr);
     183             : }
     184             : 
     185             : 
     186             : ZEND_API void _zval_internal_ptr_dtor_wrapper(zval **zval_ptr)
     187             : {
     188             :         zval_internal_ptr_dtor(zval_ptr);
     189             : }
     190             : #endif
     191             : 
     192          97 : ZEND_API int zval_copy_static_var(zval **p TSRMLS_DC, int num_args, va_list args, zend_hash_key *key) /* {{{ */
     193             : {
     194          97 :         HashTable *target = va_arg(args, HashTable*);
     195             :         zend_bool is_ref;
     196             :         zval *tmp;
     197             :   
     198          97 :         if (Z_TYPE_PP(p) & (IS_LEXICAL_VAR|IS_LEXICAL_REF)) {
     199          92 :                 is_ref = Z_TYPE_PP(p) & IS_LEXICAL_REF;
     200             :     
     201          92 :                 if (!EG(active_symbol_table)) {
     202          17 :                         zend_rebuild_symbol_table(TSRMLS_C);
     203             :                 }
     204          92 :                 if (zend_hash_quick_find(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, (void **) &p) == FAILURE) {
     205           8 :                         if (is_ref) {        
     206           4 :                                 ALLOC_INIT_ZVAL(tmp);
     207           4 :                                 Z_SET_ISREF_P(tmp);
     208           4 :                                 zend_hash_quick_add(EG(active_symbol_table), key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), (void**)&p);
     209             :                         } else {
     210           4 :                                 tmp = EG(uninitialized_zval_ptr);
     211           4 :                                 zend_error(E_NOTICE,"Undefined variable: %s", key->arKey);
     212             :                         }
     213             :                 } else {
     214          84 :                         if (is_ref) {
     215          74 :                                 SEPARATE_ZVAL_TO_MAKE_IS_REF(p);
     216          19 :                                 tmp = *p;
     217         130 :                         } else if (Z_ISREF_PP(p)) {
     218          10 :                                 ALLOC_INIT_ZVAL(tmp);
     219          10 :                                 ZVAL_COPY_VALUE(tmp, *p);
     220          10 :                                 zval_copy_ctor(tmp);
     221          10 :                                 Z_SET_REFCOUNT_P(tmp, 0);
     222          10 :                                 Z_UNSET_ISREF_P(tmp);
     223             :                         } else {
     224          55 :                                 tmp = *p;
     225             :                         }
     226             :                 }
     227             :         } else {
     228           5 :                 tmp = *p;
     229             :         }
     230          97 :         if (zend_hash_quick_add(target, key->arKey, key->nKeyLength, key->h, &tmp, sizeof(zval*), NULL) == SUCCESS) {
     231          97 :                 Z_ADDREF_P(tmp);
     232             :         }
     233          97 :         return ZEND_HASH_APPLY_KEEP;
     234             : }
     235             : /* }}} */
     236             : 
     237             : /*
     238             :  * Local variables:
     239             :  * tab-width: 4
     240             :  * c-basic-offset: 4
     241             :  * indent-tabs-mode: t
     242             :  * End:
     243             :  */

Generated by: LCOV version 1.10

Generated at Fri, 24 Oct 2014 05:21:41 +0000 (42 hours ago)

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