Back to index

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

Go to the source code of this file.

Classes

struct  _Block
struct  _StaticAllocator

Defines

#define ALLOCATOR_BLOCK_SIZE   400000
#define emalloc(s)   malloc(s)
#define efree(p)   free(p)

Typedefs

typedef unsigned int zend_uint
typedef struct _Block Block
typedef struct _StaticAllocator StaticAllocator

Functions

void static_allocator_init (StaticAllocator *sa)
char * static_allocator_allocate (StaticAllocator *sa, zend_uint size)
void static_allocator_destroy (StaticAllocator *sa)

Class Documentation

struct _Block

Definition at line 31 of file zend_static_allocator.h.

Class Members
char * bp
char * end
char * pos
struct _StaticAllocator

Definition at line 37 of file zend_static_allocator.h.

Collaboration diagram for _StaticAllocator:
Class Members
Block * Blocks
zend_uint current_block
zend_uint num_blocks

Define Documentation

#define ALLOCATOR_BLOCK_SIZE   400000

Definition at line 24 of file zend_static_allocator.h.

#define efree (   p)    free(p)

Definition at line 29 of file zend_static_allocator.h.

#define emalloc (   s)    malloc(s)

Definition at line 28 of file zend_static_allocator.h.


Typedef Documentation

typedef struct _Block Block
typedef unsigned int zend_uint

Definition at line 27 of file zend_static_allocator.h.


Function Documentation

Definition at line 53 of file zend_static_allocator.c.

{
       char *retval;

       retval = block_allocate(&sa->Blocks[sa->current_block], size);
       if (retval) {
              return retval;
       }
       sa->Blocks = (Block *) erealloc(sa->Blocks, ++sa->num_blocks);
       sa->current_block++;
       block_init(&sa->Blocks[sa->current_block], (size > ALLOCATOR_BLOCK_SIZE) ? size : ALLOCATOR_BLOCK_SIZE);
       retval = block_allocate(&sa->Blocks[sa->current_block], size);
       return retval;
}

Here is the call graph for this function:

Definition at line 68 of file zend_static_allocator.c.

{
       zend_uint i;

       for (i=0; i<sa->num_blocks; i++) {
              block_free(&sa->Blocks[i]);
       }
       efree(sa->Blocks);
}

Definition at line 45 of file zend_static_allocator.c.

{
       sa->Blocks = (Block *) emalloc(sizeof(Block));
       block_init(sa->Blocks, ALLOCATOR_BLOCK_SIZE);
       sa->num_blocks = 1;
       sa->current_block = 0;
}

Here is the call graph for this function: