00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef APR_POOLS_H
00018 #define APR_POOLS_H
00019
00037 #include "apr.h"
00038 #include "apr_errno.h"
00039 #include "apr_general.h"
00040 #define APR_WANT_MEMFUNC
00041 #include "apr_want.h"
00042
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046
00054 typedef struct apr_pool_t apr_pool_t;
00055
00056
00075 #define APR_POOL_DECLARE_ACCESSOR(type) \
00076 APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
00077 (const apr_##type##_t *the##type)
00078
00085 #define APR_POOL_IMPLEMENT_ACCESSOR(type) \
00086 APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
00087 (const apr_##type##_t *the##type) \
00088 { return the##type->pool; }
00089
00090
00126 #if defined(APR_POOL_DEBUG)
00127
00128 #if (APR_POOL_DEBUG - APR_POOL_DEBUG -1 == 1)
00129 #undef APR_POOL_DEBUG
00130 #define APR_POOL_DEBUG 1
00131 #endif
00132 #else
00133 #define APR_POOL_DEBUG 0
00134 #endif
00135
00137 #define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
00138
00139
00140
00142 typedef int (*apr_abortfunc_t)(int retcode);
00143
00144
00145
00146
00147
00148
00149
00150
00151
00158 APR_DECLARE(apr_status_t) apr_pool_initialize(void);
00159
00166 APR_DECLARE(void) apr_pool_terminate(void);
00167
00168
00169
00170
00171
00172
00173 #include "apr_allocator.h"
00174
00186 APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
00187 apr_pool_t *parent,
00188 apr_abortfunc_t abort_fn,
00189 apr_allocator_t *allocator);
00190
00207 APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
00208 apr_pool_t *parent,
00209 apr_abortfunc_t abort_fn,
00210 apr_allocator_t *allocator,
00211 const char *file_line);
00212
00213 #if APR_POOL_DEBUG
00214 #define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \
00215 apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
00216 APR_POOL__FILE_LINE__)
00217 #endif
00218
00227 #if defined(DOXYGEN)
00228 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00229 apr_pool_t *parent);
00230 #else
00231 #if APR_POOL_DEBUG
00232 #define apr_pool_create(newpool, parent) \
00233 apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00234 APR_POOL__FILE_LINE__)
00235 #else
00236 #define apr_pool_create(newpool, parent) \
00237 apr_pool_create_ex(newpool, parent, NULL, NULL)
00238 #endif
00239 #endif
00240
00245 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00246
00255 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00256
00270 APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p,
00271 const char *file_line);
00272
00273 #if APR_POOL_DEBUG
00274 #define apr_pool_clear(p) \
00275 apr_pool_clear_debug(p, APR_POOL__FILE_LINE__)
00276 #endif
00277
00284 APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
00285
00299 APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p,
00300 const char *file_line);
00301
00302 #if APR_POOL_DEBUG
00303 #define apr_pool_destroy(p) \
00304 apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__)
00305 #endif
00306
00307
00308
00309
00310
00311
00318 APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size);
00319
00328 APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size,
00329 const char *file_line);
00330
00331 #if APR_POOL_DEBUG
00332 #define apr_palloc(p, size) \
00333 apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
00334 #endif
00335
00342 #if defined(DOXYGEN)
00343 APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size);
00344 #elif !APR_POOL_DEBUG
00345 #define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size)
00346 #endif
00347
00356 APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,
00357 const char *file_line);
00358
00359 #if APR_POOL_DEBUG
00360 #define apr_pcalloc(p, size) \
00361 apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)
00362 #endif
00363
00364
00365
00366
00367
00368
00377 APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc,
00378 apr_pool_t *pool);
00379
00385 APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool);
00386
00392 APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool);
00393
00405 APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b);
00406
00412 APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag);
00413
00414
00415
00416
00417
00418
00438 APR_DECLARE(apr_status_t) apr_pool_userdata_set(
00439 const void *data,
00440 const char *key,
00441 apr_status_t (*cleanup)(void *),
00442 apr_pool_t *pool);
00443
00463 APR_DECLARE(apr_status_t) apr_pool_userdata_setn(
00464 const void *data,
00465 const char *key,
00466 apr_status_t (*cleanup)(void *),
00467 apr_pool_t *pool);
00468
00475 APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,
00476 apr_pool_t *pool);
00477
00478
00502 APR_DECLARE(void) apr_pool_cleanup_register(
00503 apr_pool_t *p,
00504 const void *data,
00505 apr_status_t (*plain_cleanup)(void *),
00506 apr_status_t (*child_cleanup)(void *));
00507
00520 APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,
00521 apr_status_t (*cleanup)(void *));
00522
00535 APR_DECLARE(void) apr_pool_child_cleanup_set(
00536 apr_pool_t *p,
00537 const void *data,
00538 apr_status_t (*plain_cleanup)(void *),
00539 apr_status_t (*child_cleanup)(void *));
00540
00552 APR_DECLARE(apr_status_t) apr_pool_cleanup_run(
00553 apr_pool_t *p,
00554 void *data,
00555 apr_status_t (*cleanup)(void *));
00556
00564 APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data);
00565
00572 APR_DECLARE(void) apr_pool_cleanup_for_exec(void);
00573
00618 #if APR_POOL_DEBUG || defined(DOXYGEN)
00619
00624 APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub);
00625
00631 APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem);
00632
00639 APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse);
00640
00646 APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag);
00647
00648
00649
00650 #else
00651
00652 #ifdef apr_pool_join
00653 #undef apr_pool_join
00654 #endif
00655 #define apr_pool_join(a,b)
00656
00657 #ifdef apr_pool_lock
00658 #undef apr_pool_lock
00659 #endif
00660 #define apr_pool_lock(pool, lock)
00661
00662 #endif
00663
00666 #ifdef __cplusplus
00667 }
00668 #endif
00669
00670 #endif