14.6. Functions

Now that we have covered the main structures used by modules, we can detail the functions available to use and manipulate those structures.

14.6.1. Pool Functions

ap_make_sub_poolcreate a subpool
pool *ap_make_sub_pool(pool *p)

Creates a subpool within a pool. The subpool is destroyed automatically when the pool p is destroyed, but can also be destroyed earlier with destroy_pool or cleared with clear_pool. Returns the new pool.

ap_clear_poolclear a pool without destroying it
void ap_clear_pool(pool *p)

Clears a pool, destroying all its subpools with destroy_pool and running cleanups. This leaves the pool itself empty but intact, and therefore available for reuse.

ap_destroy_pooldestroy a pool and all its contents
void ap_destroy_pool(pool *p)

Destroys a pool, running cleanup methods for the contents and also destroying all subpools. The subpools are destroyed before the pool's cleanups are run.

ap_bytes_in_poolreport the size of a pool
long ap_bytes_in_pool(pool *p)

Returns the number of bytes currently allocated to a pool.

ap_bytes_in_free_blocksreport the total size of free blocks in the pool system
long ap_bytes_in_free_blocks(void)

Returns the number of bytes currently in free blocks for all pools.

ap_pallocallocate memory within a pool
void *ap_palloc(pool *p, int size)

Allocates memory of at least size bytes. The memory is destroyed when the pool is destroyed. Returns a pointer to the new block of memory.

ap_pcallocallocate and clear memory within a pool
void *ap_pcalloc(pool ...

Get Apache: The Definitive Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.