Apache HTTPD
Functions | Variables
Pool Cleanup Functions

Functions

 APR_DECLARE_NONSTD (apr_status_t) apr_pool_cleanup_null(void *data)
 

Variables

const void * data
 
const void apr_status_t(* plain_cleanup )(void *)
 
const void apr_status_t(*) apr_status_t(* child_cleanup )(void *)) __attribute__((nonnull(3
 
const void apr_status_t(*) apr_status_t(* APR_DECLARE )(void) apr_pool_pre_cleanup_register(apr_pool_t *p
 

Detailed Description

Cleanups are performed in the reverse order they were registered. That is: Last In, First Out. A cleanup function can safely allocate memory from the pool that is being cleaned up. It can also safely register additional cleanups which will be run LIFO, directly after the current cleanup terminates. Cleanups have to take caution in calling functions that create subpools. Subpools, created during cleanup will NOT automatically be cleaned up. In other words, cleanups are to clean up after themselves.

Function Documentation

◆ APR_DECLARE_NONSTD()

APR_DECLARE_NONSTD ( int  )

An empty cleanup function.

Passed to apr_pool_cleanup_register() when no cleanup is required.

Parameters
dataThe data to cleanup, will not be used by this function.

Write a string to a file using a printf format.

Parameters
fptrThe file to write to.
formatThe format string
...The values to substitute in the format string
Returns
The number of bytes written

snprintf routine based on apr_vformatter. This means it understands the same extensions.

Parameters
bufThe buffer to write to
lenThe size of the buffer
formatThe format string
...The arguments to use to fill out the format string.

Iterate over a table running the provided function once for every element in the table. The varargs array must be a list of zero or more (char *) keys followed by a NULL pointer. If zero keys are given, the comp function will be invoked for every element in the table. Otherwise, the function is invoked only for those elements matching the keys specified.

If an invocation of the comp function returns zero, iteration will continue using the next specified key, if any.

Parameters
compThe function to run
recThe data to pass as the first argument to the function
tThe table to iterate over
...A varargs array of zero or more (char *) keys followed by NULL
Returns
FALSE if one of the comp() iterations returned zero; TRUE if all iterations returned non-zero
See also
apr_table_do_callback_fn_t
apr_table_vdo

Definition at line 353 of file readwrite.c.

Variable Documentation

◆ APR_DECLARE

APR_DECLARE ( void  )

Register a function to be called when a pool is cleared or destroyed.

Unlike apr_pool_cleanup_register which registers a cleanup that is called AFTER all subpools are destroyed, this function registers a function that will be called before any of the subpools are destroyed.

Parameters
pThe pool to register the cleanup with
dataThe data to pass to the cleanup function.
plain_cleanupThe function to call when the pool is cleared or destroyed

Run the specified cleanup function immediately and unregister it.

The cleanup most recently registered with p having the same values of data and cleanup will be removed and cleanup will be called with data as the argument.

Parameters
pThe pool to remove the cleanup from
dataThe data to remove from cleanup
cleanupThe function to remove from cleanup

Tear down all of the internal structures required to use pools

Remarks
Programs do NOT need to call this directly. APR will call this automatically from apr_terminate.

Clear all memory in the pool and run all the cleanups. This also destroys all subpools.

Parameters
pThe pool to clear
Remarks
This does not actually free the memory, it just allows the pool to re-use this memory for the next allocation.
See also
apr_pool_destroy()

Debug version of apr_pool_clear.

Parameters
pSee: apr_pool_clear.
file_lineWhere the function is called from. This is usually APR_POOL__FILE_LINE__.
Remarks
Only available when APR_POOL_DEBUG is defined. Call this directly if you have your apr_pool_clear calls in a wrapper function and wish to override the file_line argument to reflect the caller of your wrapper function. If you do not have apr_pool_clear in a wrapper, trust the macro and don't call apr_pool_destroy_clear directly.

Destroy the pool. This takes similar action as apr_pool_clear() and then frees all the memory.

Parameters
pThe pool to destroy
Remarks
This will actually free the memory

Debug version of apr_pool_destroy.

Parameters
pSee: apr_pool_destroy.
file_lineWhere the function is called from. This is usually APR_POOL__FILE_LINE__.
Remarks
Only available when APR_POOL_DEBUG is defined. Call this directly if you have your apr_pool_destroy calls in a wrapper function and wish to override the file_line argument to reflect the caller of your wrapper function. If you do not have apr_pool_destroy in a wrapper, trust the macro and don't call apr_pool_destroy_debug directly.

Set the function to be called when an allocation failure occurs.

Remarks
If the program wants APR to exit on a memory allocation error, then this function can be called to set the callback to use (for performing cleanup and then exiting). If this function is not called, then APR will return an error and expect the calling program to deal with the error accordingly.

Tag a pool (give it a name)

Parameters
poolThe pool to tag
tagThe tag

Register a function to be called when a pool is cleared or destroyed

Parameters
pThe pool to register the cleanup with
dataThe data to pass to the cleanup function.
plain_cleanupThe function to call when the pool is cleared or destroyed
child_cleanupThe function to call when a child process is about to exec - this function is called in the child, obviously!

Remove a previously registered cleanup function.

The cleanup most recently registered with p having the same values of data and cleanup will be removed.

Parameters
pThe pool to remove the cleanup from
dataThe data of the registered cleanup
cleanupThe function to remove from cleanup
Remarks
For some strange reason only the plain_cleanup is handled by this function

Replace the child cleanup function of a previously registered cleanup.

The cleanup most recently registered with p having the same values of data and plain_cleanup will have the registered child cleanup function replaced with child_cleanup.

Parameters
pThe pool of the registered cleanup
dataThe data of the registered cleanup
plain_cleanupThe plain cleanup function of the registered cleanup
child_cleanupThe function to register as the child cleanup

Run all registered child cleanups, in preparation for an exec() call in a forked child – close files, etc., but don't flush I/O buffers, don't wait for subprocesses, and don't free any memory.

An APR internal function for fast ucs-2 wide Unicode format conversion to the utf-8 octet-encoded Unicode. This function is used for filename and other resource conversions for platforms providing native Unicode support.

@tip Only the errors APR_EINVAL and APR_INCOMPLETE may occur, the former when the character code is invalid (in or out of context) and the later when more words were expected, but insufficient words remain.

< File is read-only

< File is executable

< all protections

< File is read-only

< File is read-only

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< File is executable

< File is executable

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

Definition at line 646 of file apr_pools.h.

◆ child_cleanup

const void apr_status_t(*) apr_status_t(* child_cleanup) (void *)) __attribute__((nonnull(3 ( void *  )

Definition at line 631 of file apr_pools.h.

◆ data

const void * data

Definition at line 629 of file apr_pools.h.

◆ plain_cleanup

const void apr_status_t(* plain_cleanup)(void *) ( void *  )

Definition at line 630 of file apr_pools.h.