Leaked source code of windows server 2003
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.

231 lines
4.6 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. #pragma once
  15. //
  16. // Types
  17. //
  18. typedef struct TAG_GROWBUFFER {
  19. PBYTE Buf;
  20. DWORD Size;
  21. DWORD End;
  22. DWORD GrowSize;
  23. DWORD UserIndex; // Unused by Growbuf. For caller use.
  24. #ifdef DEBUG
  25. DWORD StatEnd;
  26. #endif
  27. } GROWBUFFER, *PGROWBUFFER;
  28. //
  29. // Function prototypes and wrapper macros
  30. //
  31. PBYTE
  32. RealGbGrow (
  33. IN OUT PGROWBUFFER GrowBuf,
  34. IN DWORD SpaceNeeded
  35. );
  36. #define GbGrow(buf,size) DBGTRACK(PBYTE, GbGrow, (buf,size))
  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) DBGTRACK(BOOL, GbMultiSzAppendA, (buf,str))
  47. BOOL
  48. RealGbMultiSzAppendW (
  49. PGROWBUFFER GrowBuf,
  50. PCWSTR String
  51. );
  52. #define GbMultiSzAppendW(buf,str) DBGTRACK(BOOL, GbMultiSzAppendW, (buf,str))
  53. BOOL
  54. RealGbMultiSzAppendValA (
  55. PGROWBUFFER GrowBuf,
  56. PCSTR Key,
  57. DWORD Val
  58. );
  59. #define GbMultiSzAppendValA(buf,k,v) DBGTRACK(BOOL, GbMultiSzAppendValA, (buf,k,v))
  60. BOOL
  61. RealGbMultiSzAppendValW (
  62. PGROWBUFFER GrowBuf,
  63. PCWSTR Key,
  64. DWORD Val
  65. );
  66. #define GbMultiSzAppendValW(buf,k,v) DBGTRACK(BOOL, GbMultiSzAppendValW, (buf,k,v))
  67. BOOL
  68. RealGbMultiSzAppendStringA (
  69. PGROWBUFFER GrowBuf,
  70. PCSTR Key,
  71. PCSTR Val
  72. );
  73. #define GbMultiSzAppendStringA(buf,k,v) DBGTRACK(BOOL, GbMultiSzAppendStringA, (buf,k,v))
  74. BOOL
  75. RealGbMultiSzAppendStringW (
  76. PGROWBUFFER GrowBuf,
  77. PCWSTR Key,
  78. PCWSTR Val
  79. );
  80. #define GbMultiSzAppendStringW(buf,k,v) DBGTRACK(BOOL, GbMultiSzAppendStringW, (buf,k,v))
  81. BOOL
  82. RealGbAppendDword (
  83. PGROWBUFFER GrowBuf,
  84. DWORD d
  85. );
  86. #define GbAppendDword(buf,d) DBGTRACK(BOOL, GbAppendDword, (buf,d))
  87. BOOL
  88. RealGbAppendPvoid (
  89. PGROWBUFFER GrowBuf,
  90. PCVOID p
  91. );
  92. #define GbAppendPvoid(buf,p) DBGTRACK(BOOL, GbAppendPvoid, (buf,p))
  93. BOOL
  94. RealGbAppendStringA (
  95. PGROWBUFFER GrowBuf,
  96. PCSTR String
  97. );
  98. #define GbAppendStringA(buf,str) DBGTRACK(BOOL, GbAppendStringA, (buf,str))
  99. BOOL
  100. RealGbAppendStringW (
  101. PGROWBUFFER GrowBuf,
  102. PCWSTR String
  103. );
  104. #define GbAppendStringW(buf,str) DBGTRACK(BOOL, GbAppendStringW, (buf,str))
  105. BOOL
  106. RealGbAppendStringABA (
  107. PGROWBUFFER GrowBuf,
  108. PCSTR Start,
  109. PCSTR EndPlusOne
  110. );
  111. #define GbAppendStringABA(buf,a,b) DBGTRACK(BOOL, GbAppendStringABA, (buf,a,b))
  112. BOOL
  113. RealGbAppendStringABW (
  114. PGROWBUFFER GrowBuf,
  115. PCWSTR Start,
  116. PCWSTR EndPlusOne
  117. );
  118. #define GbAppendStringABW(buf,a,b) DBGTRACK(BOOL, GbAppendStringABW, (buf,a,b))
  119. BOOL
  120. RealGbCopyStringA (
  121. PGROWBUFFER GrowBuf,
  122. PCSTR String
  123. );
  124. #define GbCopyStringA(buf,str) DBGTRACK(BOOL, GbCopyStringA, (buf,str))
  125. BOOL
  126. RealGbCopyStringW (
  127. PGROWBUFFER GrowBuf,
  128. PCWSTR String
  129. );
  130. #define GbCopyStringW(buf,str) DBGTRACK(BOOL, GbCopyStringW, (buf,str))
  131. BOOL
  132. RealGbCopyQuotedStringA (
  133. PGROWBUFFER GrowBuf,
  134. PCSTR String
  135. );
  136. #define GbCopyQuotedStringA(buf,str) DBGTRACK(BOOL, GbCopyQuotedStringA, (buf,str))
  137. BOOL
  138. RealGbCopyQuotedStringW (
  139. PGROWBUFFER GrowBuf,
  140. PCWSTR String
  141. );
  142. #define GbCopyQuotedStringW(buf,str) DBGTRACK(BOOL, GbCopyQuotedStringW, (buf,str))
  143. #ifdef DEBUG
  144. VOID
  145. GbDumpStatistics (
  146. VOID
  147. );
  148. #else
  149. #define GbDumpStatistics()
  150. #endif
  151. //
  152. // A & W macros
  153. //
  154. #ifdef UNICODE
  155. #define GbMultiSzAppend GbMultiSzAppendW
  156. #define GbMultiSzAppendVal GbMultiSzAppendValW
  157. #define GbMultiSzAppendString GbMultiSzAppendStringW
  158. #define GbAppendString GbAppendStringW
  159. #define GbAppendStringAB GbAppendStringABW
  160. #define GbCopyString GbCopyStringW
  161. #define GbCopyQuotedString GbCopyQuotedStringW
  162. #else
  163. #define GbMultiSzAppend GbMultiSzAppendA
  164. #define GbMultiSzAppendVal GbMultiSzAppendValA
  165. #define GbMultiSzAppendString GbMultiSzAppendStringA
  166. #define GbAppendString GbAppendStringA
  167. #define GbAppendStringAB GbAppendStringABA
  168. #define GbCopyString GbCopyStringA
  169. #define GbCopyQuotedString GbCopyQuotedStringA
  170. #endif