axutil_allocator Struct Reference
[allocator]

Axis2 memory allocator. More...

#include <axutil_allocator.h>

List of all members.

Public Attributes

void *(* malloc_fn )(struct axutil_allocator *allocator, size_t size)
void *(* realloc )(struct axutil_allocator *allocator, void *ptr, size_t size)
void(* free_fn )(struct axutil_allocator *allocator, void *ptr)
void * local_pool
void * global_pool
void * current_pool
int global_pool_ref


Detailed Description

Axis2 memory allocator.

Encapsulator for memory allocating routines


Member Data Documentation

Memory pool currently in use. The functions axutil_allocator_switch_to_global_pool and axutil_allocator_switch_to_local_pool should be used to set the current pool to global pool or to local pool respectively.

void( * axutil_allocator::free_fn)(struct axutil_allocator *allocator, void *ptr)

Function pointer representing the function that frees memory.

Parameters:
allocator pointer to allocator struct. In the default implementation this is not used, however this parameter is useful when the allocator implementation is dealing with a memory pool.
ptr pointer to be freed
Returns:
void

Global memory pool. Global pool is used to allocate values that live beyond a request

This variable has meaning only when allocator is initialized when Axis2/C is used in Apache2 module. When switching to global poo this ref counter is increased by one. When switching to local pool it is descreased by one. When creating allocator this variable is initialized to 0 which means it points to the local pool. If user has switched to the global pool several times without switching back to the local pool this ref counter has a positive value. If at this stage switching to lcoal pool called then this ref counter is reduced and checked if its value is zero. If only it's value is zero then pool is switched to local pool. This functionality avoid unintended switching to localpool by some code fragment. Still user has to make sure that each global switch has a corresponding local switch.

Local memory pool. Local pool is used to allocate per request local values.

void*( * axutil_allocator::malloc_fn)(struct axutil_allocator *allocator, size_t size)

Function pointer representing the function that allocates memory.

Parameters:
allocator pointer to allocator struct. In the default implementation this is not used, however this parameter is useful when the allocator implementation is dealing with a memory pool.
size size of the memory block to be allocated
Returns:
pointer to the allocated memory block

void*( * axutil_allocator::realloc)(struct axutil_allocator *allocator, void *ptr, size_t size)

Function pointer representing the function that re-allocates memory.

Parameters:
allocator pointer to allocator struct. In the default implementation this is not used, however this parameter is useful when the allocator implementation is dealing with a memory pool.
ptr memory block who's size to be changed
size size of the memory block to be allocated
Returns:
pointer to the allocated memory block


The documentation for this struct was generated from the following file:

Generated on Wed Oct 14 01:02:15 2009 for Axis2/C by  doxygen 1.5.7.1