Hash :
10937304
Author :
Date :
2002-05-01T08:46:56
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
#ifndef __FT_SYSTEM_MEMORY_H__
#define __FT_SYSTEM_MEMORY_H__
#include <ft2build.h>
FT_BEGIN_HEADER
/***********************************************************************
*
* @type: FT_Memory
*
* @description:
* opaque handle to a memory manager handle. Note that since FreeType
* 2.2, the memory manager structure FT_MemoryRec is hidden to client
* applications.
*
* however, you can still define custom allocators easily using the
* @ft_memory_new API
*/
typedef struct FT_MemoryRec_* FT_Memory;
/***********************************************************************
*
* @functype: FT_Memory_AllocFunc
*
* @description:
* a function used to allocate a block of memory.
*
* @input:
* size :: size of blocks in bytes. Always > 0 !!
* mem_data :: memory-manager specific optional argument
* (see @ft_memory_new)
*
* @return:
* address of new block. NULL in case of memory exhaustion
*/
typedef FT_Pointer (*FT_Memory_AllocFunc)( FT_ULong size,
FT_Pointer mem_data );
/***********************************************************************
*
* @functype: FT_Memory_FreeFunc
*
* @description:
* a function used to release a block of memory created through
* @FT_Memory_AllocFunc or @FT_Memory_ReallocFunc
*
* @input:
* block :: address of target memory block. cannot be NULL !!
* mem_data :: memory-manager specific optional argument
* (see @ft_memory_new)
*/
typedef void (*FT_Memory_FreeFunc) ( FT_Pointer block,
FT_Pointer mem_data );
/***********************************************************************
*
* @functype: FT_Memory_ReallocFunc
*
* @description:
* a function used to reallocate a memory block.
*
* @input:
* block :: address of target memory block. cannot be NULL !!
* new_size :: new requested size in bytes
* cur_size :: current block size in bytes
* mem_data :: memory-manager specific optional argument
* (see @ft_memory_new)
*/
typedef FT_Pointer (*FT_Memory_ReallocFunc)( FT_Pointer block,
FT_ULong new_size,
FT_ULong cur_size,
FT_Pointer mem_data );
/***********************************************************************
*
* @functype: FT_Memory_CreateFunc
*
* @description:
* a function used to create a @FT_Memory object to model a
* memory manager
*
* @input:
* size :: size of memory manager structure in bytes
* init_data :: optional initialisation argument
*
* @output:
* amem_data :: memory-manager specific argument to block management
* routines.
*
* @return:
* handle to new memory manager object. NULL in case of failure
*/
typedef FT_Pointer (*FT_Memory_CreateFunc)( FT_UInt size,
FT_Pointer init_data,
FT_Pointer *amem_data );
/***********************************************************************
*
* @functype: FT_Memory_DestroyFunc
*
* @description:
* a function used to destroy a given @FT_Memory manager
*
* @input:
* memory :: target memory manager handle
* mem_data :: option manager-specific argument
*/
typedef void (*FT_Memory_DestroyFunc)( FT_Memory memory,
FT_Pointer mem_data );
/***********************************************************************
*
* @struct: FT_Memory_FuncsRec
*
* @description:
* a function used to hold all methods of a given memory manager
* implementation.
*
* @fields:
* mem_alloc :: block allocation routine
* mem_free :: block release routine
* mem_realloc :: block re-allocation routine
* mem_create :: manager creation routine
* mem_destroy :: manager destruction routine
*/
typedef struct FT_Memory_FuncsRec_
{
FT_Memory_AllocFunc mem_alloc;
FT_Memory_FreeFunc mem_free;
FT_Memory_ReallocFunc mem_realloc;
FT_Memory_CreateFunc mem_create;
FT_Memory_DestroyFunc mem_destroy;
} FT_Memory_FuncsRec, *FT_Memory_Funcs;
/***********************************************************************
*
* @type: FT_Memory_Funcs
*
* @description:
* a pointer to a constant @FT_Memory_FuncsRec structure used to
* describe a given memory manager implementation.
*/
typedef const FT_Memory_FuncsRec* FT_Memory_Funcs;
/***********************************************************************
*
* @function: ft_memory_new
*
* @description:
* create a new memory manager, given a set of memory methods
*
* @input:
* mem_funcs :: handle to memory manager implementation descriptor
* mem_init_data :: optional initialisation argument, passed to
* @FT_Memory_CreateFunc
*
* @return:
* new memory manager handle. NULL in case of failure
*/
FT_BASE( FT_Memory )
ft_memory_new( FT_Memory_Funcs mem_funcs,
FT_Pointer mem_init_data );
/***********************************************************************
*
* @function: ft_memory_destroy
*
* @description:
* destroy a given memory manager
*
* @input:
* memory :: handle to target memory manager
*/
FT_BASE( void )
ft_memory_destroy( FT_Memory memory );
/* */
FT_END_HEADER
#endif /* __FT_SYSTEM_MEMORY_H__ */