LTP GCOV extension - code coverage report
Current view: directory - Zend - zend_variables.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 41
Code covered: 90.2 % Executed lines: 37
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | Zend Engine                                                          |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1998-2007 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: zend_variables.c,v 1.62.2.1.2.2 2007/01/01 09:35:47 sebastian Exp $ */
      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                 : ZEND_API void _zval_dtor_func(zval *zvalue ZEND_FILE_LINE_DC)
      31          154268 : {
      32          154268 :         switch (zvalue->type & ~IS_CONSTANT_INDEX) {
      33                 :                 case IS_STRING:
      34                 :                 case IS_CONSTANT:
      35                 :                         CHECK_ZVAL_STRING_REL(zvalue);
      36          138642 :                         STR_FREE_REL(zvalue->value.str.val);
      37          138642 :                         break;
      38                 :                 case IS_ARRAY:
      39                 :                 case IS_CONSTANT_ARRAY: {
      40                 :                                 TSRMLS_FETCH();
      41                 : 
      42           13921 :                                 if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
      43           13702 :                                         zend_hash_destroy(zvalue->value.ht);
      44           13702 :                                         FREE_HASHTABLE(zvalue->value.ht);
      45                 :                                 }
      46                 :                         }
      47           13921 :                         break;
      48                 :                 case IS_OBJECT:
      49                 :                         {
      50                 :                                 TSRMLS_FETCH();
      51                 : 
      52             408 :                                 Z_OBJ_HT_P(zvalue)->del_ref(zvalue TSRMLS_CC);
      53                 :                         }
      54             408 :                         break;
      55                 :                 case IS_RESOURCE:
      56                 :                         {
      57                 :                                 TSRMLS_FETCH();
      58                 : 
      59                 :                                 /* destroy resource */
      60            1297 :                                 zend_list_delete(zvalue->value.lval);
      61                 :                         }
      62            1297 :                         break;
      63                 :                 case IS_LONG:
      64                 :                 case IS_DOUBLE:
      65                 :                 case IS_BOOL:
      66                 :                 case IS_NULL:
      67                 :                 default:
      68               0 :                         return;
      69                 :                         break;
      70                 :         }
      71                 : }
      72                 : 
      73                 : 
      74                 : ZEND_API void _zval_internal_dtor(zval *zvalue ZEND_FILE_LINE_DC)
      75           42930 : {
      76           42930 :         switch (zvalue->type & ~IS_CONSTANT_INDEX) {
      77                 :                 case IS_STRING:
      78                 :                 case IS_CONSTANT:
      79                 :                         CHECK_ZVAL_STRING_REL(zvalue);
      80            7884 :                         free(zvalue->value.str.val);
      81            7884 :                         break;
      82                 :                 case IS_ARRAY:
      83                 :                 case IS_CONSTANT_ARRAY:
      84                 :                 case IS_OBJECT:
      85                 :                 case IS_RESOURCE:
      86               0 :                         zend_error(E_CORE_ERROR, "Internal zval's can't be arrays, objects or resources");
      87                 :                         break;
      88                 :                 case IS_LONG:
      89                 :                 case IS_DOUBLE:
      90                 :                 case IS_BOOL:
      91                 :                 case IS_NULL:
      92                 :                 default:
      93                 :                         break;
      94                 :         }
      95           42930 : }
      96                 : 
      97                 : 
      98                 : ZEND_API void zval_add_ref(zval **p)
      99           63141 : {
     100           63141 :         (*p)->refcount++;
     101           63141 : }
     102                 : 
     103                 : 
     104                 : ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC)
     105           29626 : {
     106           29626 :         switch (zvalue->type) {
     107                 :                 case IS_RESOURCE: {
     108                 :                                 TSRMLS_FETCH();
     109                 : 
     110             165 :                                 zend_list_addref(zvalue->value.lval);
     111                 :                         }
     112             165 :                         break;
     113                 :                 case IS_BOOL:
     114                 :                 case IS_LONG:
     115                 :                 case IS_NULL:
     116               0 :                         break;
     117                 :                 case IS_CONSTANT:
     118                 :                 case IS_STRING:
     119                 :                         CHECK_ZVAL_STRING_REL(zvalue);
     120           27274 :                         zvalue->value.str.val = (char *) estrndup_rel(zvalue->value.str.val, zvalue->value.str.len);
     121           27274 :                         break;
     122                 :                 case IS_ARRAY:
     123                 :                 case IS_CONSTANT_ARRAY: {
     124                 :                                 zval *tmp;
     125            2131 :                                 HashTable *original_ht = zvalue->value.ht;
     126            2131 :                                 HashTable *tmp_ht = NULL;
     127                 :                                 TSRMLS_FETCH();
     128                 : 
     129            2131 :                                 if (zvalue->value.ht == &EG(symbol_table)) {
     130               0 :                                         return; /* do nothing */
     131                 :                                 }
     132            2131 :                                 ALLOC_HASHTABLE_REL(tmp_ht);
     133            2131 :                                 zend_hash_init(tmp_ht, zend_hash_num_elements(original_ht), NULL, ZVAL_PTR_DTOR, 0);
     134            2131 :                                 zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
     135            2131 :                                 zvalue->value.ht = tmp_ht;
     136                 :                         }
     137            2131 :                         break;
     138                 :                 case IS_OBJECT:
     139                 :                         {
     140                 :                                 TSRMLS_FETCH();
     141              56 :                                 Z_OBJ_HT_P(zvalue)->add_ref(zvalue TSRMLS_CC);
     142                 :                         }
     143                 :                         break;
     144                 :         }
     145                 : }
     146                 : 
     147                 : 
     148                 : ZEND_API int zend_print_variable(zval *var) 
     149             522 : {
     150             522 :         return zend_print_zval(var, 0);
     151                 : }
     152                 : 
     153                 : 
     154                 : #if ZEND_DEBUG
     155                 : ZEND_API void _zval_copy_ctor_wrapper(zval *zvalue)
     156                 : {
     157                 :         zval_copy_ctor(zvalue);
     158                 : }
     159                 : 
     160                 : 
     161                 : ZEND_API void _zval_dtor_wrapper(zval *zvalue)
     162                 : {
     163                 :         zval_dtor(zvalue);
     164                 : }
     165                 : 
     166                 : 
     167                 : ZEND_API void _zval_internal_dtor_wrapper(zval *zvalue)
     168                 : {
     169                 :         zval_internal_dtor(zvalue);
     170                 : }
     171                 : 
     172                 : 
     173                 : ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr)
     174                 : {
     175                 :         zval_ptr_dtor(zval_ptr);
     176                 : }
     177                 : 
     178                 : 
     179                 : ZEND_API void _zval_internal_ptr_dtor_wrapper(zval **zval_ptr)
     180                 : {
     181                 :         zval_internal_ptr_dtor(zval_ptr);
     182                 : }
     183                 : #endif
     184                 : 
     185                 : /*
     186                 :  * Local variables:
     187                 :  * tab-width: 4
     188                 :  * c-basic-offset: 4
     189                 :  * indent-tabs-mode: t
     190                 :  * End:
     191                 :  */

Generated by: LTP GCOV extension version 1.5