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: 29 48 60.4 %
Date: 2014-04-08 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2013 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       57995 : ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, zend_bool persistent)
      29             : {
      30       57995 :         stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent);
      31       57995 :         stack->max = PTR_STACK_BLOCK_SIZE;
      32       57995 :         stack->top = 0;
      33       57995 :         stack->persistent = persistent;
      34       57995 : }
      35             : 
      36       57981 : ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack)
      37             : {
      38       57981 :         zend_ptr_stack_init_ex(stack, 0);
      39       57981 : }
      40             : 
      41             : 
      42           0 : ZEND_API void zend_ptr_stack_n_push(zend_ptr_stack *stack, int count, ...)
      43             : {
      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           0 : ZEND_API void zend_ptr_stack_n_pop(zend_ptr_stack *stack, int count, ...)
      61             : {
      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       58100 : ZEND_API void zend_ptr_stack_destroy(zend_ptr_stack *stack)
      78             : {
      79       58100 :         if (stack->elements) {
      80       58100 :                 pefree(stack->elements, stack->persistent);
      81             :         }
      82       58100 : }
      83             : 
      84             : 
      85       38738 : ZEND_API void zend_ptr_stack_apply(zend_ptr_stack *stack, void (*func)(void *))
      86             : {
      87       38738 :         int i = stack->top;
      88             : 
      89       77516 :         while (--i >= 0) {
      90          40 :                 func(stack->elements[i]);
      91             :         }
      92       38738 : }
      93             : 
      94             : 
      95       38738 : ZEND_API void zend_ptr_stack_clean(zend_ptr_stack *stack, void (*func)(void *), zend_bool free_elements)
      96             : {
      97       38738 :         zend_ptr_stack_apply(stack, func);
      98       38738 :         if (free_elements) {
      99       38724 :                 int i = stack->top;
     100             : 
     101       77452 :                 while (--i >= 0) {
     102           4 :                         pefree(stack->elements[i], stack->persistent);
     103             :                 }
     104             :         }
     105       38738 :         stack->top = 0;
     106       38738 :         stack->top_element = stack->elements;
     107       38738 : }
     108             : 
     109             : 
     110          79 : ZEND_API int zend_ptr_stack_num_elements(zend_ptr_stack *stack)
     111             : {
     112          79 :         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: LCOV version 1.10

Generated at Tue, 08 Apr 2014 11:59:32 +0000 (8 days ago)

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