apr_allocator.h

Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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  * XXX: see if we can come up with something a bit better.  Currently
00103  * you can make a pool an owner, but if the pool doesn't use the allocator
00104  * the allocator will never be destroyed.
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
00139 
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 /* APR_HAS_THREADS */
00163 
00166 #ifdef __cplusplus
00167 }
00168 #endif
00169 
00170 #endif /* !APR_ALLOCATOR_H */

Generated on Mon Nov 26 11:47:26 2007 for Apache Portable Runtime by  doxygen 1.5.2