Apache2
apr_pools.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef APR_POOLS_H
18 #define APR_POOLS_H
19 
43 #include "apr.h"
44 #include "apr_errno.h"
45 #include "apr_general.h" /* for APR_STRINGIFY */
46 #define APR_WANT_MEMFUNC
47 #include "apr_want.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
60 typedef struct apr_pool_t apr_pool_t;
61 
62 
81 #define APR_POOL_DECLARE_ACCESSOR(type) \
82  APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
83  (const apr_##type##_t *the##type)
84 
91 #define APR_POOL_IMPLEMENT_ACCESSOR(type) \
92  APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
93  (const apr_##type##_t *the##type) \
94  { return the##type->pool; }
95 
96 
132 #if defined(APR_POOL_DEBUG)
133 /* If APR_POOL_DEBUG is blank, we get 1; if it is a number, we get -1. */
134 #if (APR_POOL_DEBUG - APR_POOL_DEBUG -1 == 1)
135 #undef APR_POOL_DEBUG
136 #define APR_POOL_DEBUG 1
137 #endif
138 #else
139 #define APR_POOL_DEBUG 0
140 #endif
141 
143 #define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
144 
145 
146 
148 typedef int (*apr_abortfunc_t)(int retcode);
149 
150 /*
151  * APR memory structure manipulators (pools, tables, and arrays).
152  */
153 
154 /*
155  * Initialization
156  */
157 
165 
173 
174 /*
175  * Pool creation/destruction
176  */
177 
178 #include "apr_allocator.h"
179 
196  apr_pool_t *parent,
197  apr_abortfunc_t abort_fn,
198  apr_allocator_t *allocator)
199  __attribute__((nonnull(1)));
200 
218  apr_abortfunc_t abort_fn,
219  apr_allocator_t *allocator)
220  __attribute__((nonnull(1)));
221 
239  apr_pool_t *parent,
240  apr_abortfunc_t abort_fn,
241  apr_allocator_t *allocator,
242  const char *file_line)
243  __attribute__((nonnull(1)));
244 
245 #if APR_POOL_DEBUG
246 #define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \
247  apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
248  APR_POOL__FILE_LINE__)
249 #endif
250 
267  apr_abortfunc_t abort_fn,
268  apr_allocator_t *allocator,
269  const char *file_line)
270  __attribute__((nonnull(1)));
271 
272 #if APR_POOL_DEBUG
273 #define apr_pool_create_unmanaged_ex(newpool, abort_fn, allocator) \
274  apr_pool_create_unmanaged_ex_debug(newpool, abort_fn, allocator, \
275  APR_POOL__FILE_LINE__)
276 
277 #endif
278 
291 #if defined(DOXYGEN)
293  apr_pool_t *parent);
294 #else
295 #if APR_POOL_DEBUG
296 #define apr_pool_create(newpool, parent) \
297  apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
298  APR_POOL__FILE_LINE__)
299 #else
300 #define apr_pool_create(newpool, parent) \
301  apr_pool_create_ex(newpool, parent, NULL, NULL)
302 #endif
303 #endif
304 
309 #if defined(DOXYGEN)
311 #else
312 #if APR_POOL_DEBUG
313 #define apr_pool_create_unmanaged(newpool) \
314  apr_pool_create_unmanaged_ex_debug(newpool, NULL, NULL, \
315  APR_POOL__FILE_LINE__)
316 #else
317 #define apr_pool_create_unmanaged(newpool) \
318  apr_pool_create_unmanaged_ex(newpool, NULL, NULL)
319 #endif
320 #endif
321 
327  __attribute__((nonnull(1)));
328 
338 
353  const char *file_line)
354  __attribute__((nonnull(1)));
355 
356 #if APR_POOL_DEBUG
357 #define apr_pool_clear(p) \
358  apr_pool_clear_debug(p, APR_POOL__FILE_LINE__)
359 #endif
360 
368 
383  const char *file_line)
384  __attribute__((nonnull(1)));
385 
386 #if APR_POOL_DEBUG
387 #define apr_pool_destroy(p) \
388  apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__)
389 #endif
390 
391 
392 /*
393  * Memory allocation
394  */
395 
403 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
404  __attribute__((alloc_size(2)))
405 #endif
406  __attribute__((nonnull(1)));
407 
417  const char *file_line)
418 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
419  __attribute__((alloc_size(2)))
420 #endif
421  __attribute__((nonnull(1)));
422 
423 #if APR_POOL_DEBUG
424 #define apr_palloc(p, size) \
425  apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
426 #endif
427 
434 #if defined(DOXYGEN)
436 #elif !APR_POOL_DEBUG
437 #define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size)
438 #endif
439 
449  const char *file_line)
450  __attribute__((nonnull(1)));
451 
452 #if APR_POOL_DEBUG
453 #define apr_pcalloc(p, size) \
454  apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)
455 #endif
456 
457 
458 /*
459  * Pool Properties
460  */
461 
471  apr_pool_t *pool)
472  __attribute__((nonnull(2)));
473 
480  __attribute__((nonnull(1)));
481 
488  __attribute__((nonnull(1)));
489 
502 
508 APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag)
509  __attribute__((nonnull(1)));
510 
517  __attribute__((nonnull(1)));
518 
519 /*
520  * User data management
521  */
522 
543  const char *key,
544  apr_status_t (*cleanup)(void *),
545  apr_pool_t *pool)
546  __attribute__((nonnull(2,4)));
547 
568  const void *data, const char *key,
569  apr_status_t (*cleanup)(void *),
570  apr_pool_t *pool)
571  __attribute__((nonnull(2,4)));
572 
579 APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,
580  apr_pool_t *pool)
581  __attribute__((nonnull(1,2,3)));
582 
583 
608  apr_pool_t *p, const void *data,
609  apr_status_t (*plain_cleanup)(void *),
610  apr_status_t (*child_cleanup)(void *))
611  __attribute__((nonnull(3,4)));
612 
626  apr_pool_t *p, const void *data,
627  apr_status_t (*plain_cleanup)(void *))
628  __attribute__((nonnull(3)));
629 
643  apr_status_t (*cleanup)(void *))
644  __attribute__((nonnull(3)));
645 
659  apr_pool_t *p, const void *data,
660  apr_status_t (*plain_cleanup)(void *),
661  apr_status_t (*child_cleanup)(void *))
662  __attribute__((nonnull(3,4)));
663 
676  apr_status_t (*cleanup)(void *))
677  __attribute__((nonnull(3)));
678 
687 
695 
752 
759  __attribute__((nonnull(2)));
760 
767 
775  __attribute__((nonnull(1)));
776 
783 
788 #ifdef __cplusplus
789 }
790 #endif
791 
792 #endif /* !APR_POOLS_H */
APR Platform Definitions.
APR Internal Memory Allocation.
APR Error Codes.
APR Miscellaneous library routines.
APR Standard Headers Support.
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1458
dav_buffer apr_size_t size
Definition: mod_dav.h:461
dav_buffer const void * mem
Definition: mod_dav.h:481
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:557
int
Definition: mod_proxy.h:674
void apr_pool_cleanup_for_exec(void)
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 *)) __attribute__((nonnull(3
void void apr_pool_pre_cleanup_register(apr_pool_t *p, const void *data, apr_status_t(*plain_cleanup)(void *)) __attribute__((nonnull(3)))
void apr_status_t apr_pool_cleanup_run(apr_pool_t *p, void *data, apr_status_t(*cleanup)(void *)) __attribute__((nonnull(3)))
apr_status_t apr_pool_cleanup_null(void *data)
void apr_pool_cleanup_register(apr_pool_t *p, const void *data, apr_status_t(*plain_cleanup)(void *), apr_status_t(*child_cleanup)(void *)) __attribute__((nonnull(3
void apr_pool_cleanup_kill(apr_pool_t *p, const void *data, apr_status_t(*cleanup)(void *)) __attribute__((nonnull(3)))
apr_pool_t * apr_pool_find(const void *mem)
void apr_pool_lock(apr_pool_t *pool, int flag)
void apr_pool_join(apr_pool_t *p, apr_pool_t *sub) __attribute__((nonnull(2)))
void apr_pool_owner_set(apr_pool_t *pool, apr_uint32_t flags)
apr_size_t apr_pool_num_bytes(apr_pool_t *p, int recurse) __attribute__((nonnull(1)))
struct apr_allocator_t apr_allocator_t
Definition: apr_allocator.h:41
int apr_status_t
Definition: apr_errno.h:44
unsigned int apr_uint32_t
Definition: apr.h:348
#define __attribute__(__x)
Definition: apr.h:63
size_t apr_size_t
Definition: apr.h:394
int apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b)
void apr_pool_clear(apr_pool_t *p) __attribute__((nonnull(1)))
void apr_pool_clear_debug(apr_pool_t *p, const char *file_line) __attribute__((nonnull(1)))
apr_status_t apr_status_t apr_pool_userdata_setn(const void *data, const char *key, apr_status_t(*cleanup)(void *), apr_pool_t *pool) __attribute__((nonnull(2
apr_status_t apr_pool_create_unmanaged_ex(apr_pool_t **newpool, apr_abortfunc_t abort_fn, apr_allocator_t *allocator) __attribute__((nonnull(1)))
apr_status_t apr_pool_create_ex_debug(apr_pool_t **newpool, apr_pool_t *parent, apr_abortfunc_t abort_fn, apr_allocator_t *allocator, const char *file_line) __attribute__((nonnull(1)))
int(* apr_abortfunc_t)(int retcode)
Definition: apr_pools.h:148
void apr_pool_terminate(void)
apr_status_t apr_status_t apr_status_t apr_pool_userdata_get(void **data, const char *key, apr_pool_t *pool) __attribute__((nonnull(1
apr_status_t apr_pool_userdata_set(const void *data, const char *key, apr_status_t(*cleanup)(void *), apr_pool_t *pool) __attribute__((nonnull(2
void * apr_palloc(apr_pool_t *p, apr_size_t size) __attribute__((nonnull(1)))
void apr_pool_destroy(apr_pool_t *p) __attribute__((nonnull(1)))
apr_status_t apr_pool_create_unmanaged(apr_pool_t **newpool)
apr_abortfunc_t apr_pool_abort_get(apr_pool_t *pool) __attribute__((nonnull(1)))
apr_status_t apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool, apr_abortfunc_t abort_fn, apr_allocator_t *allocator, const char *file_line) __attribute__((nonnull(1)))
const char * apr_pool_get_tag(apr_pool_t *pool) __attribute__((nonnull(1)))
apr_status_t apr_pool_create(apr_pool_t **newpool, apr_pool_t *parent)
apr_status_t apr_pool_create_ex(apr_pool_t **newpool, apr_pool_t *parent, apr_abortfunc_t abort_fn, apr_allocator_t *allocator) __attribute__((nonnull(1)))
apr_pool_t * apr_pool_parent_get(apr_pool_t *pool) __attribute__((nonnull(1)))
void * apr_palloc_debug(apr_pool_t *p, apr_size_t size, const char *file_line) __attribute__((nonnull(1)))
void apr_pool_abort_set(apr_abortfunc_t abortfunc, apr_pool_t *pool) __attribute__((nonnull(2)))
void apr_pool_tag(apr_pool_t *pool, const char *tag) __attribute__((nonnull(1)))
void apr_pool_destroy_debug(apr_pool_t *p, const char *file_line) __attribute__((nonnull(1)))
apr_status_t apr_pool_initialize(void)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
void * apr_pcalloc(apr_pool_t *p, apr_size_t size)
apr_allocator_t * apr_pool_allocator_get(apr_pool_t *pool) __attribute__((nonnull(1)))
void * apr_pcalloc_debug(apr_pool_t *p, apr_size_t size, const char *file_line) __attribute__((nonnull(1)))
#define APR_DECLARE(x)
Definition: macros.h:6
#define APR_DECLARE_NONSTD(x)
Definition: macros.h:7
apr_pool_t * p