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

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_5_3/Zend - zend_ptr_stack.c
Test: PHP Code Coverage
Date: 2009-11-21 Instrumented lines: 48
Code covered: 60.4 % Executed lines: 29
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | Zend Engine                                                          |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1998-2009 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_ptr_stack.c 272370 2008-12-31 11:15:49Z sebastian $ */
      21                 : 
      22                 : #include "zend.h"
      23                 : #include "zend_ptr_stack.h"
      24                 : #ifdef HAVE_STDARG_H
      25                 : # include <stdarg.h>
      26                 : #endif
      27                 : 
      28                 : ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent)
      29           52868 : {
      30           52868 :         stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent);
      31           52868 :         stack->max = PTR_STACK_BLOCK_SIZE;
      32           52868 :         stack->top = 0;
      33           52868 :         stack->persistent = persistent;
      34           52868 : }
      35                 : 
      36                 : ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack)
      37           52857 : {
      38           52857 :         zend_ptr_stack_init_ex(stack, 0);
      39           52857 : }
      40                 : 
      41                 : 
      42                 : ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...)
      43               0 : {
      44                 :         va_list ptr;
      45                 :         void *elem;
      46                 :         
      47               0 :         ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)
      48                 : 
      49               0 :         va_start(ptr, count);
      50               0 :         while (count>0) {
      51               0 :                 elem = va_arg(ptr, void *);
      52               0 :                 stack->top++;
      53               0 :                 *(stack->top_element++) = elem;
      54               0 :                 count--;
      55                 :         }
      56               0 :         va_end(ptr);
      57               0 : }
      58                 : 
      59                 : 
      60                 : ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...)
      61               0 : {
      62                 :         va_list ptr;
      63                 :         void **elem;
      64                 :         
      65               0 :         va_start(ptr, count);
      66               0 :         while (count>0) {
      67               0 :                 elem = va_arg(ptr, void **);
      68               0 :                 *elem = *(--stack->top_element);
      69               0 :                 stack->top--;
      70               0 :                 count--;
      71                 :         }
      72               0 :         va_end(ptr);
      73               0 : }
      74                 : 
      75                 : 
      76                 : 
      77                 : ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack)
      78           52964 : {
      79           52964 :         if (stack->elements) {
      80           52964 :                 pefree(stack->elements, stack->persistent);
      81                 :         }
      82           52964 : }
      83                 : 
      84                 : 
      85                 : ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *))
      86           35324 : {
      87           35324 :         int i = stack->top;
      88                 : 
      89           70718 :         while (--i >= 0) {
      90              70 :                 func(stack->elements[i]);
      91                 :         }
      92           35324 : }
      93                 : 
      94                 : 
      95                 : ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements)
      96           35313 : {
      97           35313 :         zend_ptr_stack_apply(stack, func);
      98           35313 :         if (free_elements) {
      99           35302 :                 int i = stack->top;
     100                 : 
     101           70608 :                 while (--i >= 0) {
     102               4 :                         pefree(stack->elements[i], stack->persistent);
     103                 :                 }
     104                 :         }
     105           35313 :         stack->top = 0;
     106           35313 :         stack->top_element = stack->elements;
     107           35313 : }
     108                 : 
     109                 : 
     110                 : ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack)
     111              73 : {
     112              73 :         return stack->top;
     113                 : }
     114                 : 
     115                 : /*
     116                 :  * Local variables:
     117                 :  * tab-width: 4
     118                 :  * c-basic-offset: 4
     119                 :  * indent-tabs-mode: t
     120                 :  * End:
     121                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Sat, 21 Nov 2009 12:26:54 +0000 (3 days ago)

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