1 #ifndef __FT_SYSTEM_MEMORY_H__
2 #define __FT_SYSTEM_MEMORY_H__
8 /************************************************************************/
9 /************************************************************************/
11 /***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/
12 /***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/
14 /************************************************************************/
15 /************************************************************************/
18 /*@**********************************************************************
23 * opaque handle to a memory manager handle. Note that since FreeType
24 * 2.2, the memory manager structure FT_MemoryRec is hidden to client
27 * however, you can still define custom allocators easily using the
30 typedef struct FT_MemoryRec_
* FT_Memory
;
33 /*@**********************************************************************
35 * @functype: FT_Memory_AllocFunc
38 * a function used to allocate a block of memory.
41 * size :: size of blocks in bytes. Always > 0 !!
42 * mem_data :: memory-manager specific optional argument
43 * (see @ft_memory_new)
46 * address of new block. NULL in case of memory exhaustion
48 typedef FT_Pointer (*FT_Memory_AllocFunc
)( FT_ULong size
,
49 FT_Pointer mem_data
);
52 /*@**********************************************************************
54 * @functype: FT_Memory_FreeFunc
57 * a function used to release a block of memory created through
58 * @FT_Memory_AllocFunc or @FT_Memory_ReallocFunc
61 * block :: address of target memory block. cannot be NULL !!
62 * mem_data :: memory-manager specific optional argument
63 * (see @ft_memory_new)
65 typedef void (*FT_Memory_FreeFunc
) ( FT_Pointer block
,
66 FT_Pointer mem_data
);
69 /*@**********************************************************************
71 * @functype: FT_Memory_ReallocFunc
74 * a function used to reallocate a memory block.
77 * block :: address of target memory block. cannot be NULL !!
78 * new_size :: new requested size in bytes
79 * cur_size :: current block size in bytes
80 * mem_data :: memory-manager specific optional argument
81 * (see @ft_memory_new)
83 typedef FT_Pointer (*FT_Memory_ReallocFunc
)( FT_Pointer block
,
86 FT_Pointer mem_data
);
89 /*@**********************************************************************
91 * @functype: FT_Memory_CreateFunc
94 * a function used to create a @FT_Memory object to model a
98 * size :: size of memory manager structure in bytes
99 * init_data :: optional initialisation argument
102 * amem_data :: memory-manager specific argument to block management
106 * handle to new memory manager object. NULL in case of failure
108 typedef FT_Pointer (*FT_Memory_CreateFunc
)( FT_UInt size
,
109 FT_Pointer init_data
,
110 FT_Pointer
*amem_data
);
113 /*@**********************************************************************
115 * @functype: FT_Memory_DestroyFunc
118 * a function used to destroy a given @FT_Memory manager
121 * memory :: target memory manager handle
122 * mem_data :: option manager-specific argument
124 typedef void (*FT_Memory_DestroyFunc
)( FT_Memory memory
,
125 FT_Pointer mem_data
);
128 /*@**********************************************************************
130 * @struct: FT_Memory_FuncsRec
133 * a function used to hold all methods of a given memory manager
137 * mem_alloc :: block allocation routine
138 * mem_free :: block release routine
139 * mem_realloc :: block re-allocation routine
140 * mem_create :: manager creation routine
141 * mem_destroy :: manager destruction routine
143 typedef struct FT_Memory_FuncsRec_
145 FT_Memory_AllocFunc mem_alloc
;
146 FT_Memory_FreeFunc mem_free
;
147 FT_Memory_ReallocFunc mem_realloc
;
148 FT_Memory_CreateFunc mem_create
;
149 FT_Memory_DestroyFunc mem_destroy
;
151 } FT_Memory_FuncsRec
, *FT_Memory_Funcs
;
154 /*@**********************************************************************
156 * @type: FT_Memory_Funcs
159 * a pointer to a constant @FT_Memory_FuncsRec structure used to
160 * describe a given memory manager implementation.
162 typedef const FT_Memory_FuncsRec
* FT_Memory_Funcs
;
165 /*@**********************************************************************
167 * @function: ft_memory_new
170 * create a new memory manager, given a set of memory methods
173 * mem_funcs :: handle to memory manager implementation descriptor
174 * mem_init_data :: optional initialisation argument, passed to
175 * @FT_Memory_CreateFunc
178 * new memory manager handle. NULL in case of failure
181 ft_memory_new( FT_Memory_Funcs mem_funcs
,
182 FT_Pointer mem_init_data
);
185 /*@**********************************************************************
187 * @function: ft_memory_destroy
190 * destroy a given memory manager
193 * memory :: handle to target memory manager
196 ft_memory_destroy( FT_Memory memory
);
202 #endif /* __FT_SYSTEM_MEMORY_H__ */