Back to index

php5  5.3.10
Functions
zend_ptr_stack.c File Reference
#include "zend.h"
#include "zend_ptr_stack.h"

Go to the source code of this file.

Functions

ZEND_API void zend_ptr_stack_init_ex (zend_ptr_stack *stack, zend_bool persistent)
ZEND_API void zend_ptr_stack_init (zend_ptr_stack *stack)
ZEND_API void zend_ptr_stack_n_push (zend_ptr_stack *stack, int count,...)
ZEND_API void zend_ptr_stack_n_pop (zend_ptr_stack *stack, int count,...)
ZEND_API void zend_ptr_stack_destroy (zend_ptr_stack *stack)
ZEND_API void zend_ptr_stack_apply (zend_ptr_stack *stack, void(*func)(void *))
ZEND_API void zend_ptr_stack_clean (zend_ptr_stack *stack, void(*func)(void *), zend_bool free_elements)
ZEND_API int zend_ptr_stack_num_elements (zend_ptr_stack *stack)

Function Documentation

ZEND_API void zend_ptr_stack_apply ( zend_ptr_stack stack,
void(*)(void *)  func 
)

Definition at line 85 of file zend_ptr_stack.c.

{
       int i = stack->top;

       while (--i >= 0) {
              func(stack->elements[i]);
       }
}

Here is the caller graph for this function:

ZEND_API void zend_ptr_stack_clean ( zend_ptr_stack stack,
void(*)(void *)  func,
zend_bool  free_elements 
)

Definition at line 95 of file zend_ptr_stack.c.

{
       zend_ptr_stack_apply(stack, func);
       if (free_elements) {
              int i = stack->top;

              while (--i >= 0) {
                     pefree(stack->elements[i], stack->persistent);
              }
       }
       stack->top = 0;
       stack->top_element = stack->elements;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 77 of file zend_ptr_stack.c.

{
       if (stack->elements) {
              pefree(stack->elements, stack->persistent);
       }
}

Here is the caller graph for this function:

Definition at line 36 of file zend_ptr_stack.c.

{
       zend_ptr_stack_init_ex(stack, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void zend_ptr_stack_init_ex ( zend_ptr_stack stack,
zend_bool  persistent 
)

Definition at line 28 of file zend_ptr_stack.c.

{
       stack->top_element = stack->elements = (void **) pemalloc(sizeof(void *)*PTR_STACK_BLOCK_SIZE, persistent);
       stack->max = PTR_STACK_BLOCK_SIZE;
       stack->top = 0;
       stack->persistent = persistent;
}

Here is the caller graph for this function:

ZEND_API void zend_ptr_stack_n_pop ( zend_ptr_stack stack,
int  count,
  ... 
)

Definition at line 60 of file zend_ptr_stack.c.

{
       va_list ptr;
       void **elem;
       
       va_start(ptr, count);
       while (count>0) {
              elem = va_arg(ptr, void **);
              *elem = *(--stack->top_element);
              stack->top--;
              count--;
       }
       va_end(ptr);
}
ZEND_API void zend_ptr_stack_n_push ( zend_ptr_stack stack,
int  count,
  ... 
)

Definition at line 42 of file zend_ptr_stack.c.

{
       va_list ptr;
       void *elem;
       
       ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)

       va_start(ptr, count);
       while (count>0) {
              elem = va_arg(ptr, void *);
              stack->top++;
              *(stack->top_element++) = elem;
              count--;
       }
       va_end(ptr);
}

Definition at line 110 of file zend_ptr_stack.c.

{
       return stack->top;
}

Here is the caller graph for this function: