Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions
zend_ptr_stack.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _zend_ptr_stack

Defines

#define PTR_STACK_BLOCK_SIZE   64
#define ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, count)
#define ZEND_PTR_STACK_NUM_ARGS   3
#define ZEND_PTR_STACK_NUM_ARGS   2

Typedefs

typedef struct _zend_ptr_stack zend_ptr_stack

Functions

ZEND_API void zend_ptr_stack_init (zend_ptr_stack *stack)
ZEND_API void zend_ptr_stack_init_ex (zend_ptr_stack *stack, zend_bool persistent)
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)
static void zend_ptr_stack_3_push (zend_ptr_stack *stack, void *a, void *b, void *c)
static void zend_ptr_stack_2_push (zend_ptr_stack *stack, void *a, void *b)
static void zend_ptr_stack_3_pop (zend_ptr_stack *stack, void **a, void **b, void **c)
static void zend_ptr_stack_2_pop (zend_ptr_stack *stack, void **a, void **b)
static void zend_ptr_stack_push (zend_ptr_stack *stack, void *ptr)
static void * zend_ptr_stack_pop (zend_ptr_stack *stack)

Class Documentation

struct _zend_ptr_stack

Definition at line 25 of file zend_ptr_stack.h.

Class Members
void ** elements
int max
zend_bool persistent
int top
void ** top_element

Define Documentation

#define PTR_STACK_BLOCK_SIZE   64

Definition at line 33 of file zend_ptr_stack.h.

#define ZEND_PTR_STACK_NUM_ARGS   3
#define ZEND_PTR_STACK_NUM_ARGS   2
#define ZEND_PTR_STACK_RESIZE_IF_NEEDED (   stack,
  count 
)
Value:
if (stack->top+count > stack->max) {                                  \
              /* we need to allocate more memory */                          \
              stack->max *= 2;                                                             \
              stack->max += count;                                                  \
              stack->elements = (void **) perealloc(stack->elements, (sizeof(void *) * (stack->max)), stack->persistent);     \
              stack->top_element = stack->elements+stack->top; \
       }

Definition at line 46 of file zend_ptr_stack.h.


Typedef Documentation


Function Documentation

static void zend_ptr_stack_2_pop ( zend_ptr_stack stack,
void **  a,
void **  b 
) [inline, static]

Definition at line 92 of file zend_ptr_stack.h.

{
       *a = *(--stack->top_element);
       *b = *(--stack->top_element);
       stack->top -= 2;
}

Here is the caller graph for this function:

static void zend_ptr_stack_2_push ( zend_ptr_stack stack,
void *  a,
void *  b 
) [inline, static]

Definition at line 71 of file zend_ptr_stack.h.

{
#define ZEND_PTR_STACK_NUM_ARGS 2

       ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)

       stack->top += ZEND_PTR_STACK_NUM_ARGS;
       *(stack->top_element++) = a;
       *(stack->top_element++) = b;

#undef ZEND_PTR_STACK_NUM_ARGS
}
static void zend_ptr_stack_3_pop ( zend_ptr_stack stack,
void **  a,
void **  b,
void **  c 
) [inline, static]

Definition at line 84 of file zend_ptr_stack.h.

{
       *a = *(--stack->top_element);
       *b = *(--stack->top_element);
       *c = *(--stack->top_element);
       stack->top -= 3;
}

Here is the caller graph for this function:

static void zend_ptr_stack_3_push ( zend_ptr_stack stack,
void *  a,
void *  b,
void *  c 
) [inline, static]

Definition at line 57 of file zend_ptr_stack.h.

{
#define ZEND_PTR_STACK_NUM_ARGS 3

       ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, ZEND_PTR_STACK_NUM_ARGS)

       stack->top += ZEND_PTR_STACK_NUM_ARGS;
       *(stack->top_element++) = a;
       *(stack->top_element++) = b;
       *(stack->top_element++) = c;

#undef ZEND_PTR_STACK_NUM_ARGS
}

Here is the caller graph for this function:

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:

static void* zend_ptr_stack_pop ( zend_ptr_stack stack) [inline, static]

Definition at line 107 of file zend_ptr_stack.h.

{
       stack->top--;
       return *(--stack->top_element);
}

Here is the caller graph for this function:

static void zend_ptr_stack_push ( zend_ptr_stack stack,
void *  ptr 
) [inline, static]

Definition at line 99 of file zend_ptr_stack.h.

{
       ZEND_PTR_STACK_RESIZE_IF_NEEDED(stack, 1)

       stack->top++;
       *(stack->top_element++) = ptr;
}

Here is the caller graph for this function: