ftsysmem.h 6.2 KB

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