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_ptr_stack.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 28 47 59.6 %
Date: 2014-09-13 Functions: 6 8 75.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 "zend.h"
      23             : #include "zend_ptr_stack.h"
      24             : #ifdef HAVE_STDARG_H
      25             : # include <stdarg.h>
      26             : #endif
      27             : 
      28       60560 : ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent)
      29             : {
      30       60560 :         stack->top_element = stack->elements = NULL;
      31       60560 :         stack->top = stack->max = 0;
      32       60560 :         stack->persistent = persistent;
      33       60560 : }
      34             : 
      35       60546 : ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack)
      36             : {
      37       60546 :         zend_ptr_stack_init_ex(stack, 0);
      38       60546 : }
      39             : 
      40             : 
      41           0 : ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...)
      42             : {
      43             :         va_list ptr;
      44             :         void *elem;
      45             :         
      46           0 :         ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)
      47             : 
      48           0 :         va_start(ptr, count);
      49           0 :         while (count>0) {
      50           0 :                 elem = va_arg(ptr, void *);
      51           0 :                 stack->top++;
      52           0 :                 *(stack->top_element++) = elem;
      53           0 :                 count--;
      54             :         }
      55           0 :         va_end(ptr);
      56           0 : }
      57             : 
      58             : 
      59           0 : ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...)
      60             : {
      61             :         va_list ptr;
      62             :         void **elem;
      63             :         
      64           0 :         va_start(ptr, count);
      65           0 :         while (count>0) {
      66           0 :                 elem = va_arg(ptr, void **);
      67           0 :                 *elem = *(--stack->top_element);
      68           0 :                 stack->top--;
      69           0 :                 count--;
      70             :         }
      71           0 :         va_end(ptr);
      72           0 : }
      73             : 
      74             : 
      75             : 
      76       60674 : ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack)
      77             : {
      78       60674 :         if (stack->elements) {
      79       19347 :                 pefree(stack->elements, stack->persistent);
      80             :         }
      81       60674 : }
      82             : 
      83             : 
      84       40454 : ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *))
      85             : {
      86       40454 :         int i = stack->top;
      87             : 
      88       80948 :         while (--i >= 0) {
      89          40 :                 func(stack->elements[i]);
      90             :         }
      91       40454 : }
      92             : 
      93             : 
      94       40454 : ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements)
      95             : {
      96       40454 :         zend_ptr_stack_apply(stack, func);
      97       40454 :         if (free_elements) {
      98       40440 :                 int i = stack->top;
      99             : 
     100       80884 :                 while (--i >= 0) {
     101           4 :                         pefree(stack->elements[i], stack->persistent);
     102             :                 }
     103             :         }
     104       40454 :         stack->top = 0;
     105       40454 :         stack->top_element = stack->elements;
     106       40454 : }
     107             : 
     108             : 
     109          76 : ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack)
     110             : {
     111          76 :         return stack->top;
     112             : }
     113             : 
     114             : /*
     115             :  * Local variables:
     116             :  * tab-width: 4
     117             :  * c-basic-offset: 4
     118             :  * indent-tabs-mode: t
     119             :  * End:
     120             :  */

Generated by: LCOV version 1.10

Generated at Sat, 13 Sep 2014 16:24:20 +0000 (5 days ago)

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