📄 apr_pools.h
字号:
/** * Tear down all of the internal structures required to use pools * @param globalp The APR global pool, used to allocate APR structures * before any other pools are created. This pool should not * ever be used outside of APR. * @remark Programs do NOT need to call this directly. APR will call this * automatically from apr_terminate. * @internal */APR_DECLARE(void) apr_pool_alloc_term(apr_pool_t *globalp); /* pool functions *//** * Create a new pool. * @param newcont The pool we have just created. * @param cont 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 it's parent pool's attributes, except the apr_pool_t will * be a sub-pool. */APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newcont, apr_pool_t *cont);/** * Set the data associated with the current pool * @param data The user data associated with the pool. * @param key The key to use for association * @param cleanup The cleanup program to use to cleanup the data * @param cont The current pool * @warning The data to be attached to the pool should have a life span * at least as long as the pool it is being attached to. * * Users of APR must take EXTREME care when choosing a key to * use for their data. It is possible to accidentally overwrite * data by choosing a key that another part of the program is using * It is advised that steps are taken to ensure that a unique * key is used at all times. * @bug Specify how to ensure this uniqueness! */APR_DECLARE(apr_status_t) apr_pool_userdata_set(const void *data, const char *key, apr_status_t (*cleanup)(void *), apr_pool_t *cont);/** * Return the data associated with the current pool. * @param data The user data associated with the pool. * @param key The key for the data to retrieve * @param cont The current pool. */APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, apr_pool_t *cont);/** * Make a sub pool from the current pool * @param p The pool to use as a parent pool * @param apr_abort A function to use if the pool cannot allocate more memory. * @return The new sub-pool * @remark The @a apr_abort function provides a way to quit the program if the * machine is out of memory. By default, APR will return on error. */APR_DECLARE(apr_pool_t *) apr_pool_sub_make(apr_pool_t *p, int (*apr_abort)(int retcode));/** * Clear all memory in the pool and run all the cleanups. This also clears all * subpools. * @param p The pool to clear * @remark This does not actually free the memory, it just allows the pool * to re-use this memory for the next allocation. * @see apr_pool_destroy() */APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);/** * Destroy the pool. This runs apr_pool_clear() and then frees all the memory. * @param p The pool to destroy * @remark This will actually free the memory */APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);/** * Report the number of bytes currently in the pool * @param p The pool to inspect * @return The number of bytes */APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p);/** * Report the number of bytes currently in the list of free blocks * @return The number of bytes */APR_DECLARE(apr_size_t) apr_pool_free_blocks_num_bytes(void);/** * Allocate a block of memory from a pool * @param c The pool to allocate from * @param reqsize The amount of memory to allocate * @return The allocated memory */APR_DECLARE(void *) apr_palloc(apr_pool_t *c, apr_size_t reqsize);/** * Allocate a block of memory from a pool and set all of the memory to 0 * @param p The pool to allocate from * @param size The amount of memory to allocate * @return The allocated memory */APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size);/** * Register a function to be called when a pool is cleared or destroyed * @param p The pool register the cleanup with * @param data The data to pass to the cleanup function. * @param plain_cleanup The function to call when the pool is cleared * or destroyed * @param child_cleanup The function to call when a child process is created - * this function is called in the child, obviously! */APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data, apr_status_t (*plain_cleanup)(void *), apr_status_t (*child_cleanup)(void *));/** * Remove a previously registered cleanup function * @param p The pool remove the cleanup from * @param data The data to remove from cleanup * @param cleanup The function to remove from cleanup * @remarks For some strange reason only the plain_cleanup is handled by this * function */APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, apr_status_t (*cleanup)(void *));/** * Run the specified cleanup function immediately and unregister it. Use * @a data instead of the data that was registered with the cleanup. * @param p The pool remove the cleanup from * @param data The data to remove from cleanup * @param cleanup The function to remove from cleanup */APR_DECLARE(apr_status_t) apr_pool_cleanup_run(apr_pool_t *p, void *data, apr_status_t (*cleanup)(void *));/* Preparing for exec() --- close files, etc., but *don't* flush I/O * buffers, *don't* wait for subprocesses, and *don't* free any memory. *//** * Run all of the child_cleanups, so that any unnecessary files are * closed because we are about to exec a new program */APR_DECLARE(void) apr_pool_cleanup_for_exec(void);/** * An empty cleanup function * @param data The data to cleanup */APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data);/* * Pool accessor functions. * * These standardized function are 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); * * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to * actually define the function. It assumes the field is named "pool". For * data types with a different field name (e.g. "cont" or "cntxt") the * APR_POOL_IMPLEMENT_ACCESSOR_X() macro should be used. * * Note: the linkage is specified for APR. It would be possible to expand * the macros to support other linkages. */#define APR_POOL_DECLARE_ACCESSOR(typename) \ APR_DECLARE(apr_pool_t *) apr_##typename##_pool_get \ (apr_##typename##_t *ob)#define APR_POOL_IMPLEMENT_ACCESSOR(typename) \ APR_POOL_IMPLEMENT_ACCESSOR_X(typename, pool)#define APR_POOL_IMPLEMENT_ACCESSOR_X(typename, fieldname) \ APR_DECLARE(apr_pool_t *) apr_##typename##_pool_get \ (apr_##typename##_t *ob) { return ob->fieldname; }/* used to guarantee to the apr_pool_t debugging code that the sub apr_pool_t * will not be destroyed before the parent pool */#ifndef APR_POOL_DEBUG# ifdef apr_pool_join# undef apr_pool_join# endif /* apr_pool_join */# define apr_pool_join(a,b)#endif /* APR_POOL_DEBUG */#ifdef __cplusplus}#endif#endif /* !APR_POOLS_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -