Back to index

php5  5.3.10
Classes | Typedefs | Functions
zend_dynamic_array.h File Reference

Go to the source code of this file.

Classes

struct  _dynamic_array

Typedefs

typedef struct _dynamic_array dynamic_array

Functions

ZEND_API int zend_dynamic_array_init (dynamic_array *da, unsigned int element_size, unsigned int size)
ZEND_API void * zend_dynamic_array_push (dynamic_array *da)
ZEND_API void * zend_dynamic_array_pop (dynamic_array *da)
ZEND_API void * zend_dynamic_array_get_element (dynamic_array *da, unsigned int index)

Class Documentation

struct _dynamic_array

Definition at line 24 of file zend_dynamic_array.c.

Class Members
unsigned int allocated
char * array
unsigned int current
unsigned int element_size
unsigned int last_used

Typedef Documentation

typedef struct _dynamic_array dynamic_array

Function Documentation

ZEND_API void* zend_dynamic_array_get_element ( dynamic_array da,
unsigned int  index 
)

Definition at line 58 of file zend_dynamic_array.c.

{
       if (index >= da->current) {
              return NULL;
       }
       return (void *)(da->array+index*da->element_size);
}
ZEND_API int zend_dynamic_array_init ( dynamic_array da,
unsigned int  element_size,
unsigned int  size 
)

Definition at line 31 of file zend_dynamic_array.c.

{
       da->element_size = element_size;
       da->allocated = size;
       da->current = 0;
       da->array = (char *) emalloc(size*element_size);
       if (da->array == NULL) {
              return 1;
       }
       return 0;
}

Definition at line 52 of file zend_dynamic_array.c.

{
       return (void *)(da->array+(--(da->current))*da->element_size);

}

Definition at line 43 of file zend_dynamic_array.c.

{
       if (da->current == da->allocated) {
              da->allocated *= 2;
              da->array = (char *) erealloc(da->array, da->allocated*da->element_size);
       }
       return (void *)(da->array+(da->current++)*da->element_size);
}