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 
00047     typedef struct axutil_allocator
00048     {
00057          void * (AXIS2_CALL *malloc_fn) (struct axutil_allocator *allocator, size_t size);
00067          void * (AXIS2_CALL *realloc) (struct axutil_allocator *allocator, void *ptr, size_t size);
00075          void (AXIS2_CALL *free_fn) (struct axutil_allocator *allocator, void *ptr);
00077          void *local_pool;
00079          void *global_pool;
00081          void *current_pool;
00082     } axutil_allocator_t;
00083 
00089     AXIS2_EXTERN axutil_allocator_t * AXIS2_CALL 
00090     axutil_allocator_init (axutil_allocator_t *allocator);
00091 
00097     AXIS2_EXTERN void AXIS2_CALL 
00098     axutil_allocator_free(axutil_allocator_t *allocator);
00099 
00108     AXIS2_EXTERN void AXIS2_CALL 
00109     axutil_allocator_switch_to_global_pool(axutil_allocator_t *allocator);
00110 
00119     AXIS2_EXTERN void AXIS2_CALL 
00120     axutil_allocator_switch_to_local_pool(axutil_allocator_t *allocator);
00121 
00122 #define AXIS2_MALLOC(allocator, size) \
00123       ((allocator)->malloc_fn(allocator, size))
00124    
00125 #define AXIS2_REALLOC(allocator, ptr, size) \
00126       ((allocator)->realloc(allocator, ptr, size))
00127       
00128 #define AXIS2_FREE(allocator, ptr) \
00129       ((allocator)->free_fn(allocator, ptr))
00130 
00133 #ifdef __cplusplus
00134 }
00135 #endif
00136 
00137 #endif    /* AXIS2_ALLOCATOR_H */

Generated on Thu May 3 12:31:01 2007 for Axis2/C by  doxygen 1.4.6