00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef APR_POOLS_H
00056 #define APR_POOLS_H
00057
00075 #include "apr.h"
00076 #include "apr_errno.h"
00077 #include "apr_general.h"
00078 #define APR_WANT_MEMFUNC
00079 #include "apr_want.h"
00080
00081 #ifdef __cplusplus
00082 extern "C" {
00083 #endif
00084
00092 typedef struct apr_pool_t apr_pool_t;
00093
00094
00113 #define APR_POOL_DECLARE_ACCESSOR(type) \
00114 APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
00115 (const apr_##type##_t *the##type)
00116
00123 #define APR_POOL_IMPLEMENT_ACCESSOR(type) \
00124 APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
00125 (const apr_##type##_t *the##type) \
00126 { return the##type->pool; }
00127
00128
00164 #if defined(APR_POOL_DEBUG)
00165 #if (APR_POOL_DEBUG != 0) && (APR_POOL_DEBUG - 0 == 0)
00166 #undef APR_POOL_DEBUG
00167 #define APR_POOL_DEBUG 1
00168 #endif
00169 #else
00170 #define APR_POOL_DEBUG 0
00171 #endif
00172
00174 #define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
00175
00176
00177
00179 typedef int (*apr_abortfunc_t)(int retcode);
00180
00181
00182
00183
00184
00185
00186
00187
00188
00195 APR_DECLARE(apr_status_t) apr_pool_initialize(void);
00196
00203 APR_DECLARE(void) apr_pool_terminate(void);
00204
00205
00206
00207
00208
00209
00210 #include "apr_allocator.h"
00211
00223 APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
00224 apr_pool_t *parent,
00225 apr_abortfunc_t abort_fn,
00226 apr_allocator_t *allocator);
00227
00244 APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
00245 apr_pool_t *parent,
00246 apr_abortfunc_t abort_fn,
00247 apr_allocator_t *allocator,
00248 const char *file_line);
00249
00250 #if APR_POOL_DEBUG
00251 #define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \
00252 apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
00253 APR_POOL__FILE_LINE__)
00254 #endif
00255
00264 #if defined(DOXYGEN)
00265 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
00266 apr_pool_t *parent);
00267 #else
00268 #if APR_POOL_DEBUG
00269 #define apr_pool_create(newpool, parent) \
00270 apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
00271 APR_POOL__FILE_LINE__)
00272 #else
00273 #define apr_pool_create(newpool, parent) \
00274 apr_pool_create_ex(newpool, parent, NULL, NULL)
00275 #endif
00276 #endif
00277
00279 #if APR_POOL_DEBUG
00280 #define apr_pool_sub_make(newpool, parent, abort_fn) \
00281 (void)apr_pool_create_ex_debug(newpool, parent, abort_fn, \
00282 NULL, \
00283 APR_POOL__FILE_LINE__)
00284 #else
00285 #define apr_pool_sub_make(newpool, parent, abort_fn) \
00286 (void)apr_pool_create_ex(newpool, parent, abort_fn, NULL)
00287 #endif
00288
00293 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
00294
00303 APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
00304
00318 APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p,
00319 const char *file_line);
00320
00321 #if APR_POOL_DEBUG
00322 #define apr_pool_clear(p) \
00323 apr_pool_clear_debug(p, APR_POOL__FILE_LINE__)
00324 #endif
00325
00332 APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
00333
00347 APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p,
00348 const char *file_line);
00349
00350 #if APR_POOL_DEBUG
00351 #define apr_pool_destroy(p) \
00352 apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__)
00353 #endif
00354
00355
00356
00357
00358
00359
00366 APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size);
00367
00376 APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size,
00377 const char *file_line);
00378
00379 #if APR_POOL_DEBUG
00380 #define apr_palloc(p, size) \
00381 apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
00382 #endif
00383
00390 #if defined(DOXYGEN)
00391 APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size);
00392 #elif !APR_POOL_DEBUG
00393 #define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size)
00394 #endif
00395
00404 APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,
00405 const char *file_line);
00406
00407 #if APR_POOL_DEBUG
00408 #define apr_pcalloc(p, size) \
00409 apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)
00410 #endif
00411
00412
00413
00414
00415
00416
00425 APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc,
00426 apr_pool_t *pool);
00427
00429 APR_DECLARE(void) apr_pool_set_abort(apr_abortfunc_t abortfunc,
00430 apr_pool_t *pool);
00431
00437 APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool);
00438
00440 APR_DECLARE(apr_abortfunc_t) apr_pool_get_abort(apr_pool_t *pool);
00441
00447 APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool);
00448
00450 APR_DECLARE(apr_pool_t *) apr_pool_get_parent(apr_pool_t *pool);
00451
00459 APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b);
00460
00466 APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag);
00467
00468
00469
00470
00471
00472
00489 APR_DECLARE(apr_status_t) apr_pool_userdata_set(
00490 const void *data,
00491 const char *key,
00492 apr_status_t (*cleanup)(void *),
00493 apr_pool_t *pool);
00494
00514 APR_DECLARE(apr_status_t) apr_pool_userdata_setn(
00515 const void *data,
00516 const char *key,
00517 apr_status_t (*cleanup)(void *),
00518 apr_pool_t *pool);
00519
00526 APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,
00527 apr_pool_t *pool);
00528
00529
00530
00531
00532
00533
00534
00535
00536
00546 APR_DECLARE(void) apr_pool_cleanup_register(
00547 apr_pool_t *p,
00548 const void *data,
00549 apr_status_t (*plain_cleanup)(void *),
00550 apr_status_t (*child_cleanup)(void *));
00551
00560 APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,
00561 apr_status_t (*cleanup)(void *));
00562
00570 APR_DECLARE(void) apr_pool_child_cleanup_set(
00571 apr_pool_t *p,
00572 const void *data,
00573 apr_status_t (*plain_cleanup)(void *),
00574 apr_status_t (*child_cleanup)(void *));
00575
00583 APR_DECLARE(apr_status_t) apr_pool_cleanup_run(
00584 apr_pool_t *p,
00585 void *data,
00586 apr_status_t (*cleanup)(void *));
00587
00592 APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data);
00593
00594
00595
00596
00601 APR_DECLARE(void) apr_pool_cleanup_for_exec(void);
00602
00603
00648 #if APR_POOL_DEBUG || defined(DOXYGEN)
00649
00654 APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub);
00655
00661 APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem);
00662
00669 APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse);
00670
00676 APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag);
00677
00678
00679
00680 #else
00681
00682 #ifdef apr_pool_join
00683 #undef apr_pool_join
00684 #endif
00685 #define apr_pool_join(a,b)
00686
00687 #ifdef apr_pool_lock
00688 #undef apr_pool_lock
00689 #endif
00690 #define apr_pool_lock(pool, lock)
00691
00692 #endif
00693
00696 #ifdef __cplusplus
00697 }
00698 #endif
00699
00700 #endif