Apache Portable Runtime
Data Structures | Macros | Typedefs | Functions
Internal Memory Allocation

Data Structures

struct  apr_memnode_t
 

Macros

#define APR_MEMNODE_T_SIZE   APR_ALIGN_DEFAULT(sizeof(apr_memnode_t))
 
#define APR_ALLOCATOR_MAX_FREE_UNLIMITED   0
 

Typedefs

typedef struct apr_allocator_t apr_allocator_t
 
typedef struct apr_memnode_t apr_memnode_t
 

Functions

apr_status_t apr_allocator_create (apr_allocator_t **allocator)
 
void apr_allocator_destroy (apr_allocator_t *allocator)
 
apr_memnode_tapr_allocator_alloc (apr_allocator_t *allocator, apr_size_t size)
 
void apr_allocator_free (apr_allocator_t *allocator, apr_memnode_t *memnode)
 
apr_size_t apr_allocator_align (apr_allocator_t *allocator, apr_size_t size)
 
void apr_allocator_owner_set (apr_allocator_t *allocator, apr_pool_t *pool)
 
apr_pool_tapr_allocator_owner_get (apr_allocator_t *allocator)
 
void apr_allocator_max_free_set (apr_allocator_t *allocator, apr_size_t size)
 
void apr_allocator_mutex_set (apr_allocator_t *allocator, apr_thread_mutex_t *mutex)
 
apr_thread_mutex_tapr_allocator_mutex_get (apr_allocator_t *allocator)
 

Detailed Description

Macro Definition Documentation

◆ APR_ALLOCATOR_MAX_FREE_UNLIMITED

#define APR_ALLOCATOR_MAX_FREE_UNLIMITED   0

Symbolic constants

◆ APR_MEMNODE_T_SIZE

#define APR_MEMNODE_T_SIZE   APR_ALIGN_DEFAULT(sizeof(apr_memnode_t))

The base size of a memory node - aligned.

Typedef Documentation

◆ apr_allocator_t

the allocator structure

◆ apr_memnode_t

typedef struct apr_memnode_t apr_memnode_t

the structure which holds information about the allocation

Function Documentation

◆ apr_allocator_align()

apr_size_t apr_allocator_align ( apr_allocator_t allocator,
apr_size_t  size 
)

Get the true size that would be allocated for the given size (including the header and alignment).

Parameters
allocatorThe allocator from which to the memory would be allocated
sizeThe size to align
Returns
The aligned size (or zero on apr_size_t overflow)

◆ apr_allocator_alloc()

apr_memnode_t* apr_allocator_alloc ( apr_allocator_t allocator,
apr_size_t  size 
)

Allocate a block of mem from the allocator

Parameters
allocatorThe allocator to allocate from
sizeThe size of the mem to allocate (excluding the memnode structure)

◆ apr_allocator_create()

apr_status_t apr_allocator_create ( apr_allocator_t **  allocator)

Create a new allocator

Parameters
allocatorThe allocator we have just created.

◆ apr_allocator_destroy()

void apr_allocator_destroy ( apr_allocator_t allocator)

Destroy an allocator

Parameters
allocatorThe allocator to be destroyed
Remarks
Any memnodes not given back to the allocator prior to destroying will not be free()d.

◆ apr_allocator_free()

void apr_allocator_free ( apr_allocator_t allocator,
apr_memnode_t memnode 
)

Free a list of blocks of mem, giving them back to the allocator. The list is typically terminated by a memnode with its next field set to NULL.

Parameters
allocatorThe allocator to give the mem back to
memnodeThe memory node to return

◆ apr_allocator_max_free_set()

void apr_allocator_max_free_set ( apr_allocator_t allocator,
apr_size_t  size 
)

Set the current threshold at which the allocator should start giving blocks back to the system.

Parameters
allocatorThe allocator to set the threshold on
sizeThe threshold. 0 == unlimited.

◆ apr_allocator_mutex_get()

apr_thread_mutex_t* apr_allocator_mutex_get ( apr_allocator_t allocator)

Get the mutex currently set for the allocator

Parameters
allocatorThe allocator

◆ apr_allocator_mutex_set()

void apr_allocator_mutex_set ( apr_allocator_t allocator,
apr_thread_mutex_t mutex 
)

Set a mutex for the allocator to use

Parameters
allocatorThe allocator to set the mutex for
mutexThe mutex

◆ apr_allocator_owner_get()

apr_pool_t* apr_allocator_owner_get ( apr_allocator_t allocator)

Get the current owner of the allocator

Parameters
allocatorThe allocator to get the owner from

◆ apr_allocator_owner_set()

void apr_allocator_owner_set ( apr_allocator_t allocator,
apr_pool_t pool 
)

Set the owner of the allocator

Parameters
allocatorThe allocator to set the owner for
poolThe pool that is to own the allocator
Remarks
Typically pool is the highest level pool using the allocator