00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef APR_ALLOCATOR_H
00018 #define APR_ALLOCATOR_H
00019
00025 #include "apr.h"
00026 #include "apr_errno.h"
00027 #define APR_WANT_MEMFUNC
00028 #include "apr_want.h"
00029
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00041 typedef struct apr_allocator_t apr_allocator_t;
00043 typedef struct apr_memnode_t apr_memnode_t;
00044
00046 struct apr_memnode_t {
00047 apr_memnode_t *next;
00048 apr_memnode_t **ref;
00049 apr_uint32_t index;
00050 apr_uint32_t free_index;
00051 char *first_avail;
00052 char *endp;
00053 };
00054
00056 #define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t))
00057
00059 #define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0
00060
00066 APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator);
00067
00074 APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator);
00075
00082 APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator,
00083 apr_size_t size);
00084
00090 APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator,
00091 apr_memnode_t *memnode);
00092
00093 #include "apr_pools.h"
00094
00101
00102
00103
00104
00105
00106 APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator,
00107 apr_pool_t *pool);
00108
00110 APR_DECLARE(void) apr_allocator_set_owner(apr_allocator_t *allocator,
00111 apr_pool_t *pool);
00112
00117 APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator);
00118
00120 APR_DECLARE(apr_pool_t *) apr_allocator_get_owner(
00121 apr_allocator_t *allocator);
00122
00129 APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
00130 apr_size_t size);
00131
00133 APR_DECLARE(void) apr_allocator_set_max_free(apr_allocator_t *allocator,
00134 apr_size_t size);
00135
00136 #include "apr_thread_mutex.h"
00137
00138 #if APR_HAS_THREADS
00144 APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator,
00145 apr_thread_mutex_t *mutex);
00146
00148 APR_DECLARE(void) apr_allocator_set_mutex(apr_allocator_t *allocator,
00149 apr_thread_mutex_t *mutex);
00150
00155 APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get(
00156 apr_allocator_t *allocator);
00157
00159 APR_DECLARE(apr_thread_mutex_t *) apr_allocator_get_mutex(
00160 apr_allocator_t *allocator);
00161
00162 #endif
00163
00166 #ifdef __cplusplus
00167 }
00168 #endif
00169
00170 #endif