⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apr_pools.h

📁 apache的软件linux版本
💻 H
📖 第 1 页 / 共 2 页
字号:
 * @param file_line Where the function is called from. *        This is usually APR_POOL__FILE_LINE__. * @return See: apr_palloc */APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size,                                     const char *file_line);#if APR_POOL_DEBUG#define apr_palloc(p, size) \    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)#endif/** * 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 */#if defined(DOXYGEN)APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size);#elif !APR_POOL_DEBUG#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size)#endif/** * Debug version of apr_pcalloc * @param p See: apr_pcalloc * @param size See: apr_pcalloc * @param file_line Where the function is called from. *        This is usually APR_POOL__FILE_LINE__. * @return See: apr_pcalloc */APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,                                      const char *file_line);#if APR_POOL_DEBUG#define apr_pcalloc(p, size) \    apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)#endif/* * Pool Properties *//** * Set the function to be called when an allocation failure occurs. * @remark 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. */APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc,                                     apr_pool_t *pool);/** @deprecated @see apr_pool_abort_set */APR_DECLARE(void) apr_pool_set_abort(apr_abortfunc_t abortfunc,                                     apr_pool_t *pool);/** * Get the abort function associated with the specified pool. * @param pool The pool for retrieving the abort function. * @return The abort function for the given pool. */APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool);/** @deprecated @see apr_pool_abort_get */APR_DECLARE(apr_abortfunc_t) apr_pool_get_abort(apr_pool_t *pool);/** * Get the parent pool of the specified pool. * @param pool The pool for retrieving the parent pool. * @return The parent of the given pool. */APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool);/** @deprecated @see apr_pool_parent_get */APR_DECLARE(apr_pool_t *) apr_pool_get_parent(apr_pool_t *pool);/** * Determine if pool a is an ancestor of pool b * @param a The pool to search * @param b The pool to search for * @return True if a is an ancestor of b, NULL is considered an ancestor *         of all pools. */APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b);/** * Tag a pool (give it a name) * @param pool The pool to tag * @param tag  The tag */APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag);/* * User data management *//** * 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 (NULL if none) * @param pool 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. *      Therefore it is advised that steps are taken to ensure that unique *      keys are used for all of the userdata objects in a particular pool *      (the same key in two different pools or a pool and one of its *      subpools is okay) at all times.  Careful namespace prefixing of *      key names is a typical way to help 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 *pool);/** * 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 (NULL if none) * @param pool The current pool * @note same as apr_pool_userdata_set(), except that this version doesn't *       make a copy of the key (this function is useful, for example, when *       the key is a string literal) * @warning This should NOT be used if the key could change addresses by *       any means between the apr_pool_userdata_setn() call and a *       subsequent apr_pool_userdata_get() on that key, such as if a *       static string is used as a userdata key in a DSO and the DSO could *       be unloaded and reloaded between the _setn() and the _get().  You *       MUST use apr_pool_userdata_set() in such cases. * @warning 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. * */APR_DECLARE(apr_status_t) apr_pool_userdata_setn(    const void *data,    const char *key,    apr_status_t (*cleanup)(void *),    apr_pool_t *pool);/** * 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 pool The current pool. */APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,                                                apr_pool_t *pool);/* * Cleanup * * Cleanups are performed in the reverse order they were registered.  That is: * Last In, First Out. *//** * 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 being *                      shutdown - 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 *));/** * Replace the child cleanup of a previously registered cleanup * @param p The pool of the registered cleanup * @param data The data of the registered cleanup * @param plain_cleanup The plain cleanup function of the registered cleanup * @param child_cleanup The function to register as the child cleanup */APR_DECLARE(void) apr_pool_child_cleanup_set(    apr_pool_t *p,    const void *data,    apr_status_t (*plain_cleanup)(void *),    apr_status_t (*child_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 *));/** * An empty cleanup function * @param data The data to cleanup */APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data);/* 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);/** * @defgroup PoolDebug Pool Debugging functions. * * pools have nested lifetimes -- sub_pools are destroyed when the * parent pool is cleared.  We allow certain liberties with operations * on things such as tables (and on other structures in a more general * sense) where we allow the caller to insert values into a table which * were not allocated from the table's pool.  The table's data will * remain valid as long as all the pools from which its values are * allocated remain valid. * * For example, if B is a sub pool of A, and you build a table T in * pool B, then it's safe to insert data allocated in A or B into T * (because B lives at most as long as A does, and T is destroyed when * B is cleared/destroyed).  On the other hand, if S is a table in * pool A, it is safe to insert data allocated in A into S, but it * is *not safe* to insert data allocated from B into S... because * B can be cleared/destroyed before A is (which would leave dangling * pointers in T's data structures). * * In general we say that it is safe to insert data into a table T * if the data is allocated in any ancestor of T's pool.  This is the * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor * relationships for all data inserted into tables.  APR_POOL_DEBUG also * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other * folks to implement similar restrictions for their own data * structures. * * However, sometimes this ancestor requirement is inconvenient -- * sometimes we're forced to create a sub pool (such as through * apr_sub_req_lookup_uri), and the sub pool is guaranteed to have * the same lifetime as the parent pool.  This is a guarantee implemented * by the *caller*, not by the pool code.  That is, the caller guarantees * they won't destroy the sub pool individually prior to destroying the * parent pool. * * In this case the caller must call apr_pool_join() to indicate this * guarantee to the APR_POOL_DEBUG code.  There are a few examples spread * through the standard modules. * * These functions are only implemented when #APR_POOL_DEBUG is set. * * @{ */#if APR_POOL_DEBUG || defined(DOXYGEN)/** * Guarantee that a subpool has the same lifetime as the parent. * @param p The parent pool * @param sub The subpool */APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub);/** * Find a pool from something allocated in it. * @param mem The thing allocated in the pool * @return The pool it is allocated in */APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem);/** * Report the number of bytes currently in the pool * @param p The pool to inspect * @param recurse Recurse/include the subpools' sizes * @return The number of bytes */APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse);/** * Lock a pool * @param pool The pool to lock * @param flag  The flag */APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag);/* @} */#else /* APR_POOL_DEBUG or DOXYGEN */#ifdef apr_pool_join#undef apr_pool_join#endif#define apr_pool_join(a,b)#ifdef apr_pool_lock#undef apr_pool_lock#endif#define apr_pool_lock(pool, lock)#endif /* APR_POOL_DEBUG or DOXYGEN *//** @} */#ifdef __cplusplus}#endif#endif /* !APR_POOLS_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -