#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__) |
the place in the code where the particular function was called
#define APR_POOL_DEBUG 0 |
Pool debug levels
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | --------------------------------- | | | | | | | | x | General debug code enabled (useful in combination with --with-efence).
| | | | | | | x | | Verbose output on stderr (report CREATE, CLEAR, DESTROY).
| | | | x | | | | | Verbose output on stderr (report PALLOC, PCALLOC).
| | | | | | x | | | Lifetime checking. On each use of a pool, check its lifetime. If the pool is out of scope, abort(). In combination with the verbose flag above, it will output LIFE in such an event prior to aborting.
| | | | | x | | | | Pool owner checking. On each use of a pool, check if the current thread is the pools owner. If not, abort(). In combination with the verbose flag above, it will output OWNER in such an event prior to aborting. Use the debug function apr_pool_owner_set() to switch a pools ownership.
When no debug level was specified, assume general debug mode. If level 0 was specified, debugging is switched off
#define APR_POOL_DECLARE_ACCESSOR | ( | type | ) |
Value:
APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ (const apr_##type##_t *the##type)
This standardized macro is used by opaque (APR) data types to return the apr_pool_t that is associated with the data type.
APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the accessor function. A typical usage and result would be:
APR_POOL_DECLARE_ACCESSOR(file); becomes: APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob);
the linkage is specified for APR. It would be possible to expand the macros to support other linkages.
#define APR_POOL_IMPLEMENT_ACCESSOR | ( | type | ) |
Value:
APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ (const apr_##type##_t *the##type) \ { return the##type->pool; }
In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to actually define the function. It assumes the field is named "pool".
typedef int(*) apr_abortfunc_t(int retcode) |
A function that is called when allocation fails.
typedef struct apr_pool_t apr_pool_t |
The fundamental pool type
void* apr_palloc | ( | apr_pool_t * | p, | |
apr_size_t | size | |||
) |
Allocate a block of memory from a pool
p | The pool to allocate from | |
size | The amount of memory to allocate |
void* apr_palloc_debug | ( | apr_pool_t * | p, | |
apr_size_t | size, | |||
const char * | file_line | |||
) |
Debug version of apr_palloc
p | See: apr_palloc | |
size | See: apr_palloc | |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
void* apr_pcalloc | ( | apr_pool_t * | p, | |
apr_size_t | size | |||
) |
Allocate a block of memory from a pool and set all of the memory to 0
p | The pool to allocate from | |
size | The amount of memory to allocate |
void* apr_pcalloc_debug | ( | apr_pool_t * | p, | |
apr_size_t | size, | |||
const char * | file_line | |||
) |
Debug version of apr_pcalloc
p | See: apr_pcalloc | |
size | See: apr_pcalloc | |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
apr_abortfunc_t apr_pool_abort_get | ( | apr_pool_t * | pool | ) |
Get the abort function associated with the specified pool.
pool | The pool for retrieving the abort function. |
void apr_pool_abort_set | ( | apr_abortfunc_t | abortfunc, | |
apr_pool_t * | pool | |||
) |
Set the function to be called when an allocation failure occurs.
apr_allocator_t* apr_pool_allocator_get | ( | apr_pool_t * | pool | ) |
Find the pools allocator
pool | The pool to get the allocator from. |
void apr_pool_clear | ( | apr_pool_t * | p | ) |
Clear all memory in the pool and run all the cleanups. This also destroys all subpools.
p | The pool to clear |
void apr_pool_clear_debug | ( | apr_pool_t * | p, | |
const char * | file_line | |||
) |
Debug version of apr_pool_clear.
p | See: apr_pool_clear. | |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
apr_status_t apr_pool_create | ( | apr_pool_t ** | newpool, | |
apr_pool_t * | parent | |||
) |
Create a new pool.
newpool | The pool we have just created. | |
parent | The parent pool. If this is NULL, the new pool is a root pool. If it is non-NULL, the new pool will inherit all of its parent pool's attributes, except the apr_pool_t will be a sub-pool. |
apr_status_t apr_pool_create_ex | ( | apr_pool_t ** | newpool, | |
apr_pool_t * | parent, | |||
apr_abortfunc_t | abort_fn, | |||
apr_allocator_t * | allocator | |||
) |
Create a new pool.
newpool | The pool we have just created. | |
parent | The parent pool. If this is NULL, the new pool is a root pool. If it is non-NULL, the new pool will inherit all of its parent pool's attributes, except the apr_pool_t will be a sub-pool. | |
abort_fn | A function to use if the pool cannot allocate more memory. | |
allocator | The allocator to use with the new pool. If NULL the allocator of the parent pool will be used. |
apr_status_t apr_pool_create_ex_debug | ( | apr_pool_t ** | newpool, | |
apr_pool_t * | parent, | |||
apr_abortfunc_t | abort_fn, | |||
apr_allocator_t * | allocator, | |||
const char * | file_line | |||
) |
Debug version of apr_pool_create_ex.
newpool |
parent |
abort_fn |
allocator |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
void apr_pool_destroy | ( | apr_pool_t * | p | ) |
Destroy the pool. This takes similar action as apr_pool_clear() and then frees all the memory.
p | The pool to destroy |
void apr_pool_destroy_debug | ( | apr_pool_t * | p, | |
const char * | file_line | |||
) |
Debug version of apr_pool_destroy.
p | See: apr_pool_destroy. | |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
apr_status_t apr_pool_initialize | ( | void | ) |
Setup all of the internal structures required to use pools
int apr_pool_is_ancestor | ( | apr_pool_t * | a, | |
apr_pool_t * | b | |||
) |
Determine if pool a is an ancestor of pool b.
a | The pool to search | |
b | The pool to search for |
apr_pool_t* apr_pool_parent_get | ( | apr_pool_t * | pool | ) |
Get the parent pool of the specified pool.
pool | The pool for retrieving the parent pool. |
void apr_pool_tag | ( | apr_pool_t * | pool, | |
const char * | tag | |||
) |
Tag a pool (give it a name)
pool | The pool to tag | |
tag | The tag |
void apr_pool_terminate | ( | void | ) |
Tear down all of the internal structures required to use pools
apr_status_t apr_pool_userdata_get | ( | void ** | data, | |
const char * | key, | |||
apr_pool_t * | pool | |||
) |
Return the data associated with the current pool.
data | The user data associated with the pool. | |
key | The key for the data to retrieve | |
pool | The current pool. |
apr_status_t apr_pool_userdata_set | ( | const void * | data, | |
const char * | key, | |||
apr_status_t(*)(void *) | cleanup, | |||
apr_pool_t * | pool | |||
) |
Set the data associated with the current pool
data | The user data associated with the pool. | |
key | The key to use for association | |
cleanup | The cleanup program to use to cleanup the data (NULL if none) | |
pool | The current pool |
apr_status_t apr_pool_userdata_setn | ( | const void * | data, | |
const char * | key, | |||
apr_status_t(*)(void *) | cleanup, | |||
apr_pool_t * | pool | |||
) |
Set the data associated with the current pool
data | The user data associated with the pool. | |
key | The key to use for association | |
cleanup | The cleanup program to use to cleanup the data (NULL if none) | |
pool | The current pool |
More generally, the key and the data to be attached to the pool should have a life span at least as long as the pool itself.