Back to index

php5  5.3.10
Functions
zend_static_allocator.c File Reference
#include "zend_static_allocator.h"

Go to the source code of this file.

Functions

static void block_init (Block *block, zend_uint block_size)
static char * block_allocate (Block *block, zend_uint size)
static void block_destroy (Block *block)
void static_allocator_init (StaticAllocator *sa)
char * static_allocator_allocate (StaticAllocator *sa, zend_uint size)
void static_allocator_destroy (StaticAllocator *sa)

Function Documentation

static char* block_allocate ( Block block,
zend_uint  size 
) [inline, static]

Definition at line 31 of file zend_static_allocator.c.

{
       char *retval = block->pos;
       if ((block->pos += size) >= block->end) {
              return (char *)NULL;
       }
       return retval;
}

Here is the caller graph for this function:

static void block_destroy ( Block block) [inline, static]

Definition at line 40 of file zend_static_allocator.c.

{
       efree(block->bp);
}
static void block_init ( Block block,
zend_uint  block_size 
) [inline, static]

Definition at line 25 of file zend_static_allocator.c.

{
       block->pos = block->bp = (char *) emalloc(block_size);
       block->end = block->bp + block_size;
}

Here is the caller graph for this function:

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: