• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files

apr_pools.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_POOLS_H
00018 #define APR_POOLS_H
00019 
00020 /**
00021  * @file apr_pools.h
00022  * @brief APR memory allocation
00023  *
00024  * Resource allocation routines...
00025  *
00026  * designed so that we don't have to keep track of EVERYTHING so that
00027  * it can be explicitly freed later (a fundamentally unsound strategy ---
00028  * particularly in the presence of die()).
00029  *
00030  * Instead, we maintain pools, and allocate items (both memory and I/O
00031  * handlers) from the pools --- currently there are two, one for
00032  * per-transaction info, and one for config info.  When a transaction is
00033  * over, we can delete everything in the per-transaction apr_pool_t without
00034  * fear, and without thinking too hard about it either.
00035  *
00036  * Note that most operations on pools are not thread-safe: a single pool
00037  * should only be accessed by a single thread at any given time. The one
00038  * exception to this rule is creating a subpool of a given pool: one or more
00039  * threads can safely create subpools at the same time that another thread
00040  * accesses the parent pool.
00041  */
00042 
00043 #include "apr.h"
00044 #include "apr_errno.h"
00045 #include "apr_general.h" /* for APR_STRINGIFY */
00046 #define APR_WANT_MEMFUNC /**< for no good reason? */
00047 #include "apr_want.h"
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00053 /**
00054  * @defgroup apr_pools Memory Pool Functions
00055  * @ingroup APR 
00056  * @{
00057  */
00058 
00059 /** The fundamental pool type */
00060 typedef struct apr_pool_t apr_pool_t;
00061 
00062 
00063 /**
00064  * Declaration helper macro to construct apr_foo_pool_get()s.
00065  *
00066  * This standardized macro is used by opaque (APR) data types to return
00067  * the apr_pool_t that is associated with the data type.
00068  *
00069  * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the
00070  * accessor function. A typical usage and result would be:
00071  * <pre>
00072  *    APR_POOL_DECLARE_ACCESSOR(file);
00073  * becomes:
00074  *    APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob);
00075  * </pre>
00076  * @remark Doxygen unwraps this macro (via doxygen.conf) to provide 
00077  * actual help for each specific occurance of apr_foo_pool_get.
00078  * @remark the linkage is specified for APR. It would be possible to expand
00079  *       the macros to support other linkages.
00080  */
00081 #define APR_POOL_DECLARE_ACCESSOR(type) \
00082     APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
00083         (const apr_##type##_t *the##type)
00084 
00085 /** 
00086  * Implementation helper macro to provide apr_foo_pool_get()s.
00087  *
00088  * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to
00089  * actually define the function. It assumes the field is named "pool".
00090  */
00091 #define APR_POOL_IMPLEMENT_ACCESSOR(type) \
00092     APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
00093             (const apr_##type##_t *the##type) \
00094         { return the##type->pool; }
00095 
00096 
00097 /**
00098  * Pool debug levels
00099  *
00100  * <pre>
00101  * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
00102  * ---------------------------------
00103  * |   |   |   |   |   |   |   | x |  General debug code enabled (useful in
00104  *                                    combination with --with-efence).
00105  *
00106  * |   |   |   |   |   |   | x |   |  Verbose output on stderr (report
00107  *                                    CREATE, CLEAR, DESTROY).
00108  *
00109  * |   |   |   | x |   |   |   |   |  Verbose output on stderr (report
00110  *                                    PALLOC, PCALLOC).
00111  *
00112  * |   |   |   |   |   | x |   |   |  Lifetime checking. On each use of a
00113  *                                    pool, check its lifetime.  If the pool
00114  *                                    is out of scope, abort().
00115  *                                    In combination with the verbose flag
00116  *                                    above, it will output LIFE in such an
00117  *                                    event prior to aborting.
00118  *
00119  * |   |   |   |   | x |   |   |   |  Pool owner checking.  On each use of a
00120  *                                    pool, check if the current thread is the
00121  *                                    pools owner.  If not, abort().  In
00122  *                                    combination with the verbose flag above,
00123  *                                    it will output OWNER in such an event
00124  *                                    prior to aborting.  Use the debug
00125  *                                    function apr_pool_owner_set() to switch
00126  *                                    a pools ownership.
00127  *
00128  * When no debug level was specified, assume general debug mode.
00129  * If level 0 was specified, debugging is switched off
00130  * </pre>
00131  */
00132 #if defined(APR_POOL_DEBUG)
00133 /* If APR_POOL_DEBUG is blank, we get 1; if it is a number, we get -1. */
00134 #if (APR_POOL_DEBUG - APR_POOL_DEBUG -1 == 1)
00135 #undef APR_POOL_DEBUG
00136 #define APR_POOL_DEBUG 1
00137 #endif
00138 #else
00139 #define APR_POOL_DEBUG 0
00140 #endif
00141 
00142 /** the place in the code where the particular function was called */
00143 #define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
00144 
00145 
00146 
00147 /** A function that is called when allocation fails. */
00148 typedef int (*apr_abortfunc_t)(int retcode);
00149 
00150 /*
00151  * APR memory structure manipulators (pools, tables, and arrays).
00152  */
00153 
00154 /*
00155  * Initialization
00156  */
00157 
00158 /**
00159  * Setup all of the internal structures required to use pools
00160  * @remark Programs do NOT need to call this directly.  APR will call this
00161  *      automatically from apr_initialize.
00162  * @internal
00163  */
00164 APR_DECLARE(apr_status_t) apr_pool_initialize(void);
00165 
00166 /**
00167  * Tear down all of the internal structures required to use pools
00168  * @remark Programs do NOT need to call this directly.  APR will call this
00169  *      automatically from apr_terminate.
00170  * @internal
00171  */
00172 APR_DECLARE(void) apr_pool_terminate(void);
00173 
00174 
00175 /*
00176  * Pool creation/destruction
00177  */
00178 
00179 #include "apr_allocator.h"
00180 
00181 /**
00182  * Create a new pool.
00183  * @param newpool The pool we have just created.
00184  * @param parent The parent pool.  If this is NULL, the new pool is a root
00185  *        pool.  If it is non-NULL, the new pool will inherit all
00186  *        of its parent pool's attributes, except the apr_pool_t will
00187  *        be a sub-pool.
00188  * @param abort_fn A function to use if the pool cannot allocate more memory.
00189  * @param allocator The allocator to use with the new pool.  If NULL the
00190  *        allocator of the parent pool will be used.
00191  * @remark This function is thread-safe, in the sense that multiple threads
00192  *         can safely create subpools of the same parent pool concurrently.
00193  *         Similarly, a subpool can be created by one thread at the same
00194  *         time that another thread accesses the parent pool.
00195  */
00196 APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
00197                                              apr_pool_t *parent,
00198                                              apr_abortfunc_t abort_fn,
00199                                              apr_allocator_t *allocator);
00200 
00201 /**
00202  * Create a new pool.
00203  * @deprecated @see apr_pool_create_unmanaged_ex.
00204  */
00205 APR_DECLARE(apr_status_t) apr_pool_create_core_ex(apr_pool_t **newpool,
00206                                                   apr_abortfunc_t abort_fn,
00207                                                   apr_allocator_t *allocator);
00208 
00209 /**
00210  * Create a new unmanaged pool.
00211  * @param newpool The pool we have just created.
00212  * @param abort_fn A function to use if the pool cannot allocate more memory.
00213  * @param allocator The allocator to use with the new pool.  If NULL a
00214  *        new allocator will be crated with newpool as owner.
00215  * @remark An unmanaged pool is a special pool without a parent; it will
00216  *         NOT be destroyed upon apr_terminate.  It must be explicitly
00217  *         destroyed by calling apr_pool_destroy, to prevent memory leaks.
00218  *         Use of this function is discouraged, think twice about whether
00219  *         you really really need it.
00220  */
00221 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
00222                                                    apr_abortfunc_t abort_fn,
00223                                                    apr_allocator_t *allocator);
00224 
00225 /**
00226  * Debug version of apr_pool_create_ex.
00227  * @param newpool @see apr_pool_create.
00228  * @param parent @see apr_pool_create.
00229  * @param abort_fn @see apr_pool_create.
00230  * @param allocator @see apr_pool_create.
00231  * @param file_line Where the function is called from.
00232  *        This is usually APR_POOL__FILE_LINE__.
00233  * @remark Only available when APR_POOL_DEBUG is defined.
00234  *         Call this directly if you have you apr_pool_create_ex
00235  *         calls in a wrapper function and wish to override
00236  *         the file_line argument to reflect the caller of
00237  *         your wrapper function.  If you do not have
00238  *         apr_pool_create_ex in a wrapper, trust the macro
00239  *         and don't call apr_pool_create_ex_debug directly.
00240  */
00241 APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
00242                                                    apr_pool_t *parent,
00243                                                    apr_abortfunc_t abort_fn,
00244                                                    apr_allocator_t *allocator,
00245                                                    const char *file_line);
00246 
00247 #if APR_POOL_DEBUG
00248 #define apr_pool_create_ex(newpool, parent, abort_fn, allocator)  \
00249     apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
00250                              APR_POOL__FILE_LINE__)
00251 #endif
00252 
00253 /**
00254  * Debug version of apr_pool_create_core_ex.
00255  * @deprecated @see apr_pool_create_unmanaged_ex_debug.
00256  */
00257 APR_DECLARE(apr_status_t) apr_pool_create_core_ex_debug(apr_pool_t **newpool,
00258                                                    apr_abortfunc_t abort_fn,
00259                                                    apr_allocator_t *allocator,
00260                                                    const char *file_line);
00261 
00262 /**
00263  * Debug version of apr_pool_create_unmanaged_ex.
00264  * @param newpool @see apr_pool_create_unmanaged.
00265  * @param abort_fn @see apr_pool_create_unmanaged.
00266  * @param allocator @see apr_pool_create_unmanaged.
00267  * @param file_line Where the function is called from.
00268  *        This is usually APR_POOL__FILE_LINE__.
00269  * @remark Only available when APR_POOL_DEBUG is defined.
00270  *         Call this directly if you have you apr_pool_create_unmanaged_ex
00271  *         calls in a wrapper function and wish to override
00272  *         the file_line argument to reflect the caller of
00273  *         your wrapper function.  If you do not have
00274  *         apr_pool_create_core_ex in a wrapper, trust the macro
00275  *         and don't call apr_pool_create_core_ex_debug directly.
00276  */
00277 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool,
00278                                                    apr_abortfunc_t abort_fn,
00279                                                    apr_allocator_t *allocator,
00280                                                    const char *file_line);
00281 
00282 #if APR_POOL_DEBUG
00283 #define apr_pool_create_core_ex(newpool, abort_fn, allocator)  \
00284     apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, \
00285                                   APR_POOL__FILE_LINE__)
00286 
00287 #define apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator)  \
00288     apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, \
00289                                   APR_POOL__FILE_LINE__)
00290 
00291 #endif
00292 
00293 /**
00294  * Create a new pool.
00295  * @param newpool The pool we have just created.
00296  * @param parent The parent pool.  If this is NULL, the new pool is a root
00297  *        pool.  If it is non-NULL, the new pool will inherit all
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352  * @remark This does not actually free the memory, it just allows the pool
00353  *         to re-use this memory for the next allocation.
00354  * @see apr_pool_destroy()
00355  */
00356 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00357 
00358 /**
00359  * Debug version of apr_pool_clear.
00360  * @param p See: apr_pool_clear.
00361  * @param file_line Where the function is called from.
00362  *        This is usually APR_POOL__FILE_LINE__.
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352  * @remark This does not actually free the memory, it just allows the pool
00353  *         to re-use this memory for the next allocation.
00354  * @see apr_pool_destroy()
00355  */
00356 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00357 
00358 /**
00359  * Debug version of apr_pool_clear.
00360  * @param p See: apr_pool_clear.
00361  * @param file_line Where the function is called from.
00362  *        This is usually APR_POOL__FILE_LINE__.
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352  * @remark This does not actually free the memory, it just allows the pool
00353  *         to re-use this memory for the next allocation.
00354  * @see apr_pool_destroy()
00355  */
00356 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00357 
00358 /**
00359  * Debug version of apr_pool_clear.
00360  * @param p See: apr_pool_clear.
00361  * @param file_line Where the function is called from.
00362  *        This is usually APR_POOL__FILE_LINE__.
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352  * @remark This does not actually free the memory, it just allows the pool
00353  *         to re-use this memory for the next allocation.
00354  * @see apr_pool_destroy()
00355  */
00356 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00357 
00358 /**
00359  * Debug version of apr_pool_clear.
00360  * @param p See: apr_pool_clear.
00361  * @param file_line Where the function is called from.
00362  *        This is usually APR_POOL__FILE_LINE__.
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352  * @remark This does not actually free the memory, it just allows the pool
00353  *         to re-use this memory for the next allocation.
00354  * @see apr_pool_destroy()
00355  */
00356 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00357 
00358 /**
00359  * Debug version of apr_pool_clear.
00360  * @param p See: apr_pool_clear.
00361  * @param file_line Where the function is called from.
00362  *        This is usually APR_POOL__FILE_LINE__.
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352  * @remark This does not actually free the memory, it just allows the pool
00353  *         to re-use this memory for the next allocation.
00354  * @see apr_pool_destroy()
00355  */
00356 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00357 
00358 /**
00359  * Debug version of apr_pool_clear.
00360  * @param p See: apr_pool_clear.
00361  * @param file_line Where the function is called from.
00362  *        This is usually APR_POOL__FILE_LINE__.
00298  *        of its parent pool's attributes, except the apr_pool_t will
00299  *        be a sub-pool.
00300  * @remark This function is thread-safe, in the sense that multiple threads
00301  *         can safely create subpools of the same parent pool concurrently.
00302  *         Similarly, a subpool can be created by one thread at the same
00303  *         time that another thread accesses the parent pool.
00304  */
00305 #if defined(DOXYGEN)
00306 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00307                                           apr_pool_t *parent);
00308 #else
00309 #if APR_POOL_DEBUG
00310 #define apr_pool_create(newpool, parent) \
00311     apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00312                              APR_POOL__FILE_LINE__)
00313 #else
00314 #define apr_pool_create(newpool, parent) \
00315     apr_pool_create_ex(newpool, parent, NULL, NULL)
00316 #endif
00317 #endif
00318 
00319 /**
00320  * Create a new pool.
00321  * @param newpool The pool we have just created.
00322  */
00323 #if defined(DOXYGEN)
00324 APR_DECLARE(apr_status_t) apr_pool_create_core(apr_pool_t **newpool);
00325 APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
00326 #else
00327 #if APR_POOL_DEBUG
00328 #define apr_pool_create_core(newpool) \
00329     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00330                                   APR_POOL__FILE_LINE__)
00331 #define apr_pool_create_unmanaged(newpool) \
00332     apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
00333                                   APR_POOL__FILE_LINE__)
00334 #else
00335 #define apr_pool_create_core(newpool) \
00336     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00337 #define apr_pool_create_unmanaged(newpool) \
00338     apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
00339 #endif
00340 #endif
00341 
00342 /**
00343  * Find the pool's allocator
00344  * @param pool The pool to get the allocator from.
00345  */
00346 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00347 
00348 /**
00349  * Clear all memory in the pool and run all the cleanups. This also destroys all
00350  * subpools.
00351  * @param p The pool to clear
00352