axutil_allocator.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef AXUTIL_ALLOCATOR_H
00019 #define AXUTIL_ALLOCATOR_H
00020 
00026 #include <axutil_utils_defines.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C"
00030 {
00031 #endif
00032 
00044     typedef struct axutil_allocator
00045     {
00046 
00055         void *(
00056             AXIS2_CALL
00057             * malloc_fn)(
00058                 struct axutil_allocator * allocator,
00059                 size_t size);
00060 
00070         void *(
00071             AXIS2_CALL
00072             * realloc)(
00073                 struct axutil_allocator * allocator,
00074                 void *ptr,
00075                 size_t size);
00076 
00085         void(
00086             AXIS2_CALL
00087             * free_fn)(
00088                 struct axutil_allocator * allocator,
00089                 void *ptr);
00090 
00095         void *local_pool;
00096 
00101         void *global_pool;
00102 
00109         void *current_pool;
00110 
00111         void *pool_allocator;
00112         int ref_pool_allocator;
00113 
00114         void(
00115             AXIS2_CALL
00116             * pool_allocator_destroy)(
00117                 struct axutil_allocator * allocator);
00118 
00119     }
00120     axutil_allocator_t;
00121 
00128     AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL
00129     axutil_allocator_init(
00130         axutil_allocator_t * allocator);
00131 
00138     AXIS2_EXTERN void AXIS2_CALL
00139     axutil_allocator_free(
00140         axutil_allocator_t * allocator);
00141 
00152     AXIS2_EXTERN void AXIS2_CALL
00153     axutil_allocator_switch_to_global_pool(
00154         axutil_allocator_t * allocator);
00155 
00166     AXIS2_EXTERN void AXIS2_CALL
00167     axutil_allocator_switch_to_local_pool(
00168         axutil_allocator_t * allocator);
00169 
00170 #define AXIS2_MALLOC(allocator, size) \
00171       ((allocator)->malloc_fn(allocator, size))
00172 
00173 #define AXIS2_REALLOC(allocator, ptr, size) \
00174       ((allocator)->realloc(allocator, ptr, size))
00175 
00176 #define AXIS2_FREE(allocator, ptr) \
00177       ((allocator)->free_fn(allocator, ptr))
00178 
00179 #define AXIS2_POOL_ALLOCATOR_DESTROY(allocator) \
00180       ((allocator)->pool_allocator_destroy(allocator))  
00181 
00182 
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188 
00189 #endif                          /* AXIS2_ALLOCATOR_H */

Generated on Fri Jul 11 11:56:35 2008 for Axis2/C by  doxygen 1.5.5