Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

apr_allocator.h

Go to the documentation of this file.
00001 /* Copyright 2000-2004 The Apache Software Foundation 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 00016 #ifndef APR_ALLOCATOR_H 00017 #define APR_ALLOCATOR_H 00018 00024 #include "apr.h" 00025 #include "apr_errno.h" 00026 #define APR_WANT_MEMFUNC 00027 #include "apr_want.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00040 typedef struct apr_allocator_t apr_allocator_t; 00042 typedef struct apr_memnode_t apr_memnode_t; 00043 00045 struct apr_memnode_t { 00046 apr_memnode_t *next; 00047 apr_memnode_t **ref; 00048 apr_uint32_t index; 00049 apr_uint32_t free_index; 00050 char *first_avail; 00051 char *endp; 00052 }; 00053 00055 #define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t)) 00056 00058 #define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0 00059 00065 APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator); 00066 00073 APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator); 00074 00081 APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, 00082 apr_size_t size); 00083 00089 APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, 00090 apr_memnode_t *memnode); 00091 00092 #include "apr_pools.h" 00093 00100 /* 00101 * XXX: see if we can come up with something a bit better. Currently 00102 * you can make a pool an owner, but if the pool doesn't use the allocator 00103 * the allocator will never be destroyed. 00104 */ 00105 APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator, 00106 apr_pool_t *pool); 00107 00109 APR_DECLARE(void) apr_allocator_set_owner(apr_allocator_t *allocator, 00110 apr_pool_t *pool); 00111 00116 APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator); 00117 00119 APR_DECLARE(apr_pool_t *) apr_allocator_get_owner( 00120 apr_allocator_t *allocator); 00121 00128 APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, 00129 apr_size_t size); 00130 00132 APR_DECLARE(void) apr_allocator_set_max_free(apr_allocator_t *allocator, 00133 apr_size_t size); 00134 00135 #include "apr_thread_mutex.h" 00136 00137 #if APR_HAS_THREADS 00143 APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, 00144 apr_thread_mutex_t *mutex); 00145 00147 APR_DECLARE(void) apr_allocator_set_mutex(apr_allocator_t *allocator, 00148 apr_thread_mutex_t *mutex); 00149 00154 APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( 00155 apr_allocator_t *allocator); 00156 00158 APR_DECLARE(apr_thread_mutex_t *) apr_allocator_get_mutex( 00159 apr_allocator_t *allocator); 00160 00161 #endif /* APR_HAS_THREADS */ 00162 00165 #ifdef __cplusplus 00166 } 00167 #endif 00168 00169 #endif /* !APR_ALLOCATOR_H */

Generated on Tue Aug 10 17:42:34 2004 for Apache Portable Runtime by doxygen 1.3.7