y_malloc.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * <library name="y_malloc">
  3. * <section>
  4. * Description
  5. * </section>
  6. * Functions for using malloc/calloc/free type functions in PAWN.
  7. * <section>
  8. * Version
  9. * </section>
  10. * 0.1
  11. * <section>
  12. * Functions
  13. * </section>
  14. * <subsection>
  15. * Stock
  16. * </subsection><ul>
  17. * <symbol name="malloc">Allocate a block of memory (may be inline).</symbol>
  18. * <symbol name="calloc">Allocate a block of memory and blank.</symbol>
  19. * <symbol name="free">Free an allocated block of memory (may be inline).</symbol>
  20. * <symbol name="Malloc_Set">Set a value in an allocated array (may be inline).</symbol>
  21. * <symbol name="Malloc_Get">Get a value in an allocated array (may be inline).</symbol>
  22. * <symbol name="Malloc_SetS">Set a string in an allocated array.</symbol>
  23. * <symbol name="Malloc_GetS">Get a string in an allocated array.</symbol>
  24. * <symbol name="Malloc_Allocate">Do the memory allocation (may be static).</symbol>
  25. * <symbol name="Malloc_Free">Do the memory freeing (may be static).</symbol>
  26. * <symbol name="Malloc_SlotSize">Get the size of an allocated block (may be inline).</symbol>
  27. * <symbol name="Malloc_NewS">Allocate for and store a given string.</symbol>
  28. * </ul><subsection>
  29. * Static
  30. * </subsection><ul>
  31. * <symbol name="Malloc_Allocate">Do the memory allocation (may be stock).</symbol>
  32. * <symbol name="Malloc_Free">Do the memory freeing (may be stock).</symbol>
  33. * </ul><subsection>
  34. * Inline
  35. * </subsection><ul>
  36. * <symbol name="mget">Get data from an allocation unit.</symbol>
  37. * <symbol name="mset">Set data in an allocation unit.</symbol>
  38. * <symbol name="mgets">Get a string from an allocation unit.</symbol>
  39. * <symbol name="msets">Set a string in an allocation unit.</symbol>
  40. * <symbol name="malloc">Allocate a block of memory (may be stock).</symbol>
  41. * <symbol name="free">Free an allocated block of memory (may be stock).</symbol>
  42. * <symbol name="Malloc_Set">Set a value in an allocated array (may be stock).</symbol>
  43. * <symbol name="Malloc_Get">Get a value in an allocated array (may be stock).</symbol>
  44. * <symbol name="Malloc_NextSlot">Get the next free data block.</symbol>
  45. * <symbol name="Malloc_GetSlotSize">Get the size of a slot.</symbol>
  46. * <symbol name="Malloc_SetSlotSize">Set the size of a block.</symbol>
  47. * <symbol name="Malloc_GetData">Direct data access getter.</symbol>
  48. * <symbol name="Malloc_SetData">Direct data access setter.</symbol>
  49. * <symbol name="Malloc_SlotSize">Get the size of an allocated block (may be stock).</symbol>
  50. * </ul><section>
  51. * Definitions
  52. * </section><ul>
  53. * <symbol name="MALLOC_KB_TO_CELL">Multiplication value to convert kb to cells.</symbol>
  54. * <symbol name="NO_ALLOC">A failed allocation (NULL, but YSI already has NULL).</symbol>
  55. * </ul><section>
  56. * Tags
  57. * </section><ul>
  58. * <symbol name="Alloc">An allocated block handle variable.</symbol>
  59. * </ul><section>
  60. * Variables
  61. * </section>
  62. * <subsection>
  63. * Global
  64. * </subsection><ul>
  65. * <symbol name="YSI_gMallocMemory">Stores the data (may be static).</symbol>
  66. * </ul><subsection>
  67. * Static
  68. * </subsection><ul>
  69. * <symbol name="YSI_gMallocMemory">Stores the data (may be global).</symbol>
  70. * <symbol name="_YSI_g_sUnusedStart">Start of free memory.</symbol>
  71. * </ul><section>Compile options</section><ul>
  72. * <symbol name="MALLOC_MEMORY">Number of cells to reserve.</symbol>
  73. * <symbol name="MALLOC_MEMORY_KB">Number of killobytes to reserve.</symbol>
  74. * <symbol name="MALLOC_MEMORY_B">Number of bytes to reserve.</symbol>
  75. * <symbol name="MALLOC_MEMORY_MB">Number of megabytes to reserve.</symbol>
  76. * <symbol name="YSI_MALLOC_SECURE">Use enhanced bounds checking.</symbol>
  77. * <symbol name="YSI_MALLOC_NO_SHORT">Avoid conflicts with mget/mset.</symbol>
  78. * </ul>
  79. * </library>
  80. *//** *//*
  81. Legal:
  82. Version: MPL 1.1
  83. The contents of this file are subject to the Mozilla Public License Version
  84. 1.1 the "License"; you may not use this file except in compliance with
  85. the License. You may obtain a copy of the License at
  86. http://www.mozilla.org/MPL/
  87. Software distributed under the License is distributed on an "AS IS" basis,
  88. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  89. for the specific language governing rights and limitations under the
  90. License.
  91. The Original Code is the YSI framework.
  92. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  93. Portions created by the Initial Developer are Copyright C 2011
  94. the Initial Developer. All Rights Reserved.
  95. Contributors:
  96. Y_Less
  97. koolk
  98. JoeBullet/Google63
  99. g_aSlice/Slice
  100. Misiur
  101. samphunter
  102. tianmeta
  103. maddinat0r
  104. spacemud
  105. Crayder
  106. Dayvison
  107. Ahmad45123
  108. Zeex
  109. irinel1996
  110. Yiin-
  111. Chaprnks
  112. Konstantinos
  113. Masterchen09
  114. Southclaws
  115. PatchwerkQWER
  116. m0k1
  117. paulommu
  118. udan111
  119. Thanks:
  120. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  121. ZeeX - Very productive conversations.
  122. koolk - IsPlayerinAreaEx code.
  123. TheAlpha - Danish translation.
  124. breadfish - German translation.
  125. Fireburn - Dutch translation.
  126. yom - French translation.
  127. 50p - Polish translation.
  128. Zamaroht - Spanish translation.
  129. Los - Portuguese translation.
  130. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  131. me to strive to better.
  132. Pixels^ - Running XScripters where the idea was born.
  133. Matite - Pestering me to release it and using it.
  134. Very special thanks to:
  135. Thiadmer - PAWN, whose limits continue to amaze me!
  136. Kye/Kalcor - SA:MP.
  137. SA:MP Team past, present and future - SA:MP.
  138. Optional plugins:
  139. Gamer_Z - GPS.
  140. Incognito - Streamer.
  141. Me - sscanf2, fixes2, Whirlpool.
  142. */
  143. #if !defined _INC_y_malloc
  144. #tryinclude "y_malloc\y_malloc_entry"
  145. #endif
  146. #if !defined _INC_y_malloc
  147. #tryinclude "YSI_Coding\y_malloc\y_malloc_entry"
  148. #endif
  149. #if !defined _INC_y_malloc
  150. #tryinclude "YSI\YSI_Coding\y_malloc\y_malloc_entry"
  151. #endif
  152. #if !defined _INC_y_malloc
  153. #tryinclude <YSI_Coding\y_malloc\y_malloc_entry>
  154. #endif
  155. #if !defined _INC_y_malloc
  156. #tryinclude <YSI\YSI_Coding\y_malloc\y_malloc_entry>
  157. #endif
  158. #if !defined _INC_y_malloc
  159. #error Could not find y_malloc
  160. #endif