Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. growbuf.h
  5. Abstract:
  6. Implements the GROWBUFFER data type, a dynamically allocated buffer
  7. that grows (and potentially changes addresses). GROWBUFFERs are
  8. typically used to maintain dynamic sized arrays, or multi-sz lists.
  9. Author:
  10. Jim Schmidt (jimschm) 25-Feb-1997
  11. Revision History:
  12. <alias> <date> <comments>
  13. --*/
  14. typedef struct TAG_GROWBUFFER {
  15. PBYTE Buf;
  16. DWORD Size;
  17. DWORD End;
  18. DWORD GrowSize;
  19. DWORD UserIndex; // Unused by Growbuf. For caller use.
  20. #ifdef DEBUG
  21. DWORD StatEnd;
  22. #endif
  23. } GROWBUFFER;
  24. #ifdef DEBUG
  25. #define INIT_GROWBUFFER {NULL,0,0,0,0,0}
  26. #else
  27. #define INIT_GROWBUFFER {NULL,0,0,0,0}
  28. #endif
  29. PBYTE
  30. RealGbGrow (
  31. IN OUT PGROWBUFFER GrowBuf,
  32. IN DWORD SpaceNeeded
  33. );
  34. #define GbGrow(buf,size) TRACK_BEGIN(PBYTE, GbGrow)\
  35. RealGbGrow(buf,size)\
  36. TRACK_END()
  37. VOID
  38. GbFree (
  39. IN PGROWBUFFER GrowBuf
  40. );
  41. BOOL
  42. RealGbMultiSzAppendA (
  43. PGROWBUFFER GrowBuf,
  44. PCSTR String
  45. );
  46. #define GbMultiSzAppendA(buf,str) TRACK_BEGIN(BOOL, GbMultiSzAppendA)\
  47. RealGbMultiSzAppendA(buf,str)\
  48. TRACK_END()
  49. BOOL
  50. RealGbMultiSzAppendW (
  51. PGROWBUFFER GrowBuf,
  52. PCWSTR String
  53. );
  54. #define GbMultiSzAppendW(buf,str) TRACK_BEGIN(BOOL, GbMultiSzAppendW)\
  55. RealGbMultiSzAppendW(buf,str)\
  56. TRACK_END()
  57. BOOL
  58. RealGbMultiSzAppendValA (
  59. PGROWBUFFER GrowBuf,
  60. PCSTR Key,
  61. DWORD Val
  62. );
  63. #define GbMultiSzAppendValA(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendValA)\
  64. RealGbMultiSzAppendValA(buf,k,v)\
  65. TRACK_END()
  66. BOOL
  67. RealGbMultiSzAppendValW (
  68. PGROWBUFFER GrowBuf,
  69. PCWSTR Key,
  70. DWORD Val
  71. );
  72. #define GbMultiSzAppendValW(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendValW)\
  73. RealGbMultiSzAppendValW(buf,k,v)\
  74. TRACK_END()
  75. BOOL
  76. RealGbMultiSzAppendStringA (
  77. PGROWBUFFER GrowBuf,
  78. PCSTR Key,
  79. PCSTR Val
  80. );
  81. #define GbMultiSzAppendStringA(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendStringA)\
  82. RealGbMultiSzAppendStringA(buf,k,v)\
  83. TRACK_END()
  84. BOOL
  85. RealGbMultiSzAppendStringW (
  86. PGROWBUFFER GrowBuf,
  87. PCWSTR Key,
  88. PCWSTR Val
  89. );
  90. #define GbMultiSzAppendStringW(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendStringW)\
  91. RealGbMultiSzAppendStringW(buf,k,v)\
  92. TRACK_END()
  93. BOOL
  94. RealGbAppendDword (
  95. PGROWBUFFER GrowBuf,
  96. DWORD d
  97. );
  98. #define GbAppendDword(buf,d) TRACK_BEGIN(BOOL, GbAppendDword)\
  99. RealGbAppendDword(buf,d)\
  100. TRACK_END()
  101. BOOL
  102. RealGbAppendPvoid (
  103. PGROWBUFFER GrowBuf,
  104. PCVOID p
  105. );
  106. #define GbAppendPvoid(buf,p) TRACK_BEGIN(BOOL, GbAppendPvoid)\
  107. RealGbAppendPvoid(buf,p)\
  108. TRACK_END()
  109. BOOL
  110. RealGbAppendStringA (
  111. PGROWBUFFER GrowBuf,
  112. PCSTR String
  113. );
  114. #define GbAppendStringA(buf,str) TRACK_BEGIN(BOOL, GbAppendStringA)\
  115. RealGbAppendStringA(buf,str)\
  116. TRACK_END()
  117. BOOL
  118. RealGbAppendStringW (
  119. PGROWBUFFER GrowBuf,
  120. PCWSTR String
  121. );
  122. #define GbAppendStringW(buf,str) TRACK_BEGIN(BOOL, GbAppendStringW)\
  123. RealGbAppendStringW(buf,str)\
  124. TRACK_END()
  125. BOOL
  126. RealGbAppendStringABA (
  127. PGROWBUFFER GrowBuf,
  128. PCSTR Start,
  129. PCSTR EndPlusOne
  130. );
  131. #define GbAppendStringABA(buf,a,b) TRACK_BEGIN(BOOL, GbAppendStringABA)\
  132. RealGbAppendStringABA(buf,a,b)\
  133. TRACK_END()
  134. BOOL
  135. RealGbAppendStringABW (
  136. PGROWBUFFER GrowBuf,
  137. PCWSTR Start,
  138. PCWSTR EndPlusOne
  139. );
  140. #define GbAppendStringABW(buf,a,b) TRACK_BEGIN(BOOL, GbAppendStringABW)\
  141. RealGbAppendStringABW(buf,a,b)\
  142. TRACK_END()
  143. BOOL
  144. RealGbCopyStringA (
  145. PGROWBUFFER GrowBuf,
  146. PCSTR String
  147. );
  148. #define GbCopyStringA(buf,str) TRACK_BEGIN(BOOL, GbCopyStringA)\
  149. RealGbCopyStringA(buf,str)\
  150. TRACK_END()
  151. BOOL
  152. RealGbCopyStringW (
  153. PGROWBUFFER GrowBuf,
  154. PCWSTR String
  155. );
  156. #define GbCopyStringW(buf,str) TRACK_BEGIN(BOOL, GbCopyStringW)\
  157. RealGbCopyStringW(buf,str)\
  158. TRACK_END()
  159. BOOL
  160. RealGbCopyQuotedStringA (
  161. PGROWBUFFER GrowBuf,
  162. PCSTR String
  163. );
  164. #define GbCopyQuotedStringA(buf,str) TRACK_BEGIN(BOOL, GbCopyQuotedStringA)\
  165. RealGbCopyQuotedStringA(buf,str)\
  166. TRACK_END()
  167. BOOL
  168. RealGbCopyQuotedStringW (
  169. PGROWBUFFER GrowBuf,
  170. PCWSTR String
  171. );
  172. #define GbCopyQuotedStringW(buf,str) TRACK_BEGIN(BOOL, GbCopyQuotedStringW)\
  173. RealGbCopyQuotedStringW(buf,str)\
  174. TRACK_END()
  175. #ifdef DEBUG
  176. VOID
  177. GbDumpStatistics (
  178. VOID
  179. );
  180. #else
  181. #define GbDumpStatistics()
  182. #endif
  183. #ifdef UNICODE
  184. #define GbMultiSzAppend GbMultiSzAppendW
  185. #define GbMultiSzAppendVal GbMultiSzAppendValW
  186. #define GbMultiSzAppendString GbMultiSzAppendStringW
  187. #define GbAppendString GbAppendStringW
  188. #define GbAppendStringAB GbAppendStringABW
  189. #define GbCopyString GbCopyStringW
  190. #define GbCopyQuotedString GbCopyQuotedStringW
  191. #else
  192. #define GbMultiSzAppend GbMultiSzAppendA
  193. #define GbMultiSzAppendVal GbMultiSzAppendValA
  194. #define GbMultiSzAppendString GbMultiSzAppendStringA
  195. #define GbAppendString GbAppendStringA
  196. #define GbAppendStringAB GbAppendStringABA
  197. #define GbCopyString GbCopyStringA
  198. #define GbCopyQuotedString GbCopyQuotedStringA
  199. #endif