axutil_allocator.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef AXUTIL_ALLOCATOR_H
00019 #define AXUTIL_ALLOCATOR_H
00020
00026 #include <axutil_utils_defines.h>
00027 #include <stdlib.h>
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
00123 int global_pool_ref;
00124
00125 }
00126 axutil_allocator_t;
00127
00134 AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL
00135 axutil_allocator_init(
00136 axutil_allocator_t * allocator);
00137
00143 AXIS2_EXTERN axutil_allocator_t *AXIS2_CALL
00144 axutil_allocator_clone(
00145 axutil_allocator_t * allocator);
00146
00153 AXIS2_EXTERN void AXIS2_CALL
00154 axutil_allocator_free(
00155 axutil_allocator_t * allocator);
00156
00167 AXIS2_EXTERN void AXIS2_CALL
00168 axutil_allocator_switch_to_global_pool(
00169 axutil_allocator_t * allocator);
00170
00181 AXIS2_EXTERN void AXIS2_CALL
00182 axutil_allocator_switch_to_local_pool(
00183 axutil_allocator_t * allocator);
00184
00185 #define AXIS2_MALLOC(allocator, size) \
00186 ((allocator)->malloc_fn(allocator, size))
00187
00188 #define AXIS2_REALLOC(allocator, ptr, size) \
00189 ((allocator)->realloc(allocator, ptr, size))
00190
00191 #define AXIS2_FREE(allocator, ptr) \
00192 ((allocator)->free_fn(allocator, ptr))
00193
00196 #ifdef __cplusplus
00197 }
00198 #endif
00199
00200 #endif