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

Generated by: LCOV version 1.10

Generated at Tue, 22 Jul 2014 01:33:03 +0000 (9 days ago)

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