Bringing apdf from vendor into main branch.
[AROS-Contrib.git] / apdf / freetype2 / include / freetype / ftsysmem.h
blob70fe6b5201f5ab02e85a5d72e3bb8172c5aa624e
1 #ifndef __FT_SYSTEM_MEMORY_H__
2 #define __FT_SYSTEM_MEMORY_H__
4 #include <ft2build.h>
6 FT_BEGIN_HEADER
8 /***********************************************************************
10 * @type: FT_Memory
12 * @description:
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
15 * applications.
17 * however, you can still define custom allocators easily using the
18 * @ft_memory_new API
20 typedef struct FT_MemoryRec_* FT_Memory;
23 /***********************************************************************
25 * @functype: FT_Memory_AllocFunc
27 * @description:
28 * a function used to allocate a block of memory.
30 * @input:
31 * size :: size of blocks in bytes. Always > 0 !!
32 * mem_data :: memory-manager specific optional argument
33 * (see @ft_memory_new)
35 * @return:
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
46 * @description:
47 * a function used to release a block of memory created through
48 * @FT_Memory_AllocFunc or @FT_Memory_ReallocFunc
50 * @input:
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
63 * @description:
64 * a function used to reallocate a memory block.
66 * @input:
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,
74 FT_ULong new_size,
75 FT_ULong cur_size,
76 FT_Pointer mem_data );
79 /***********************************************************************
81 * @functype: FT_Memory_CreateFunc
83 * @description:
84 * a function used to create a @FT_Memory object to model a
85 * memory manager
87 * @input:
88 * size :: size of memory manager structure in bytes
89 * init_data :: optional initialisation argument
91 * @output:
92 * amem_data :: memory-manager specific argument to block management
93 * routines.
95 * @return:
96 * handle to new memory manager object. NULL in case of failure
98 typedef FT_Pointer (*FT_Memory_CreateFunc)( FT_UInt size,
99 FT_Pointer init_data,
100 FT_Pointer *amem_data );
103 /***********************************************************************
105 * @functype: FT_Memory_DestroyFunc
107 * @description:
108 * a function used to destroy a given @FT_Memory manager
110 * @input:
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
122 * @description:
123 * a function used to hold all methods of a given memory manager
124 * implementation.
126 * @fields:
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
148 * @description:
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
159 * @description:
160 * create a new memory manager, given a set of memory methods
162 * @input:
163 * mem_funcs :: handle to memory manager implementation descriptor
164 * mem_init_data :: optional initialisation argument, passed to
165 * @FT_Memory_CreateFunc
167 * @return:
168 * new memory manager handle. NULL in case of failure
170 FT_BASE( FT_Memory )
171 ft_memory_new( FT_Memory_Funcs mem_funcs,
172 FT_Pointer mem_init_data );
175 /***********************************************************************
177 * @function: ft_memory_destroy
179 * @description:
180 * destroy a given memory manager
182 * @input:
183 * memory :: handle to target memory manager
185 FT_BASE( void )
186 ft_memory_destroy( FT_Memory memory );
188 /* */
190 FT_END_HEADER
192 #endif /* __FT_SYSTEM_MEMORY_H__ */