1 #ifndef __FT_SYSTEM_MEMORY_H__
2 #define __FT_SYSTEM_MEMORY_H__
8 /***********************************************************************
13 * opaque handle to a memory manager handle. Note that since FreeType
14 * 2.2, the memory manager structure FT_MemoryRec is hidden to client
17 * however, you can still define custom allocators easily using the
20 typedef struct FT_MemoryRec_
* FT_Memory
;
23 /***********************************************************************
25 * @functype: FT_Memory_AllocFunc
28 * a function used to allocate a block of memory.
31 * size :: size of blocks in bytes. Always > 0 !!
32 * mem_data :: memory-manager specific optional argument
33 * (see @ft_memory_new)
36 * address of new block. NULL in case of memory exhaustion
38 typedef FT_Pointer (*FT_Memory_AllocFunc
)( FT_ULong size
,
39 FT_Pointer mem_data
);
42 /***********************************************************************
44 * @functype: FT_Memory_FreeFunc
47 * a function used to release a block of memory created through
48 * @FT_Memory_AllocFunc or @FT_Memory_ReallocFunc
51 * block :: address of target memory block. cannot be NULL !!
52 * mem_data :: memory-manager specific optional argument
53 * (see @ft_memory_new)
55 typedef void (*FT_Memory_FreeFunc
) ( FT_Pointer block
,
56 FT_Pointer mem_data
);
59 /***********************************************************************
61 * @functype: FT_Memory_ReallocFunc
64 * a function used to reallocate a memory block.
67 * block :: address of target memory block. cannot be NULL !!
68 * new_size :: new requested size in bytes
69 * cur_size :: current block size in bytes
70 * mem_data :: memory-manager specific optional argument
71 * (see @ft_memory_new)
73 typedef FT_Pointer (*FT_Memory_ReallocFunc
)( FT_Pointer block
,
76 FT_Pointer mem_data
);
79 /***********************************************************************
81 * @functype: FT_Memory_CreateFunc
84 * a function used to create a @FT_Memory object to model a
88 * size :: size of memory manager structure in bytes
89 * init_data :: optional initialisation argument
92 * amem_data :: memory-manager specific argument to block management
96 * handle to new memory manager object. NULL in case of failure
98 typedef FT_Pointer (*FT_Memory_CreateFunc
)( FT_UInt size
,
100 FT_Pointer
*amem_data
);
103 /***********************************************************************
105 * @functype: FT_Memory_DestroyFunc
108 * a function used to destroy a given @FT_Memory manager
111 * memory :: target memory manager handle
112 * mem_data :: option manager-specific argument
114 typedef void (*FT_Memory_DestroyFunc
)( FT_Memory memory
,
115 FT_Pointer mem_data
);
118 /***********************************************************************
120 * @struct: FT_Memory_FuncsRec
123 * a function used to hold all methods of a given memory manager
127 * mem_alloc :: block allocation routine
128 * mem_free :: block release routine
129 * mem_realloc :: block re-allocation routine
130 * mem_create :: manager creation routine
131 * mem_destroy :: manager destruction routine
133 typedef struct FT_Memory_FuncsRec_
135 FT_Memory_AllocFunc mem_alloc
;
136 FT_Memory_FreeFunc mem_free
;
137 FT_Memory_ReallocFunc mem_realloc
;
138 FT_Memory_CreateFunc mem_create
;
139 FT_Memory_DestroyFunc mem_destroy
;
141 } FT_Memory_FuncsRec
, *FT_Memory_Funcs
;
144 /***********************************************************************
146 * @type: FT_Memory_Funcs
149 * a pointer to a constant @FT_Memory_FuncsRec structure used to
150 * describe a given memory manager implementation.
152 typedef const FT_Memory_FuncsRec
* FT_Memory_Funcs
;
155 /***********************************************************************
157 * @function: ft_memory_new
160 * create a new memory manager, given a set of memory methods
163 * mem_funcs :: handle to memory manager implementation descriptor
164 * mem_init_data :: optional initialisation argument, passed to
165 * @FT_Memory_CreateFunc
168 * new memory manager handle. NULL in case of failure
171 ft_memory_new( FT_Memory_Funcs mem_funcs
,
172 FT_Pointer mem_init_data
);
175 /***********************************************************************
177 * @function: ft_memory_destroy
180 * destroy a given memory manager
183 * memory :: handle to target memory manager
186 ft_memory_destroy( FT_Memory memory
);
192 #endif /* __FT_SYSTEM_MEMORY_H__ */