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.

220 lines
5.9 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 {
  15. PBYTE Buf;
  16. DWORD Size;
  17. DWORD End;
  18. DWORD GrowSize;
  19. DWORD UserIndex; // Unused by Growbuf. For caller use.
  20. } GROWBUFFER, *PGROWBUFFER;
  21. #define GROWBUF_INIT {NULL,0,0,0,0}
  22. PBYTE
  23. RealGrowBuffer (
  24. IN OUT PGROWBUFFER GrowBuf,
  25. IN DWORD SpaceNeeded
  26. );
  27. #define GrowBuffer(buf,size) SETTRACKCOMMENT(PBYTE,"GrowBuffer",__FILE__,__LINE__)\
  28. RealGrowBuffer(buf,size)\
  29. CLRTRACKCOMMENT
  30. VOID
  31. FreeGrowBuffer (
  32. IN PGROWBUFFER GrowBuf
  33. );
  34. PBYTE
  35. RealGrowBufferReserve (
  36. IN OUT PGROWBUFFER GrowBuf,
  37. IN DWORD SpaceNeeded
  38. );
  39. #define GrowBufferReserve(buf,size) SETTRACKCOMMENT(PBYTE,"GrowBufferReserve",__FILE__,__LINE__)\
  40. RealGrowBufferReserve(buf,size)\
  41. CLRTRACKCOMMENT
  42. BOOL
  43. RealMultiSzAppendA (
  44. PGROWBUFFER GrowBuf,
  45. PCSTR String
  46. );
  47. #define MultiSzAppendA(buf,str) SETTRACKCOMMENT(BOOL,"MultiSzAppendA",__FILE__,__LINE__)\
  48. RealMultiSzAppendA(buf,str)\
  49. CLRTRACKCOMMENT
  50. BOOL
  51. RealMultiSzAppendW (
  52. PGROWBUFFER GrowBuf,
  53. PCWSTR String
  54. );
  55. #define MultiSzAppendW(buf,str) SETTRACKCOMMENT(BOOL,"MultiSzAppendW",__FILE__,__LINE__)\
  56. RealMultiSzAppendW(buf,str)\
  57. CLRTRACKCOMMENT
  58. BOOL
  59. RealMultiSzAppendValA (
  60. PGROWBUFFER GrowBuf,
  61. PCSTR Key,
  62. DWORD Val
  63. );
  64. #define MultiSzAppendValA(buf,k,v) SETTRACKCOMMENT(BOOL,"MultiSzAppendValA",__FILE__,__LINE__)\
  65. RealMultiSzAppendValA(buf,k,v)\
  66. CLRTRACKCOMMENT
  67. BOOL
  68. RealMultiSzAppendValW (
  69. PGROWBUFFER GrowBuf,
  70. PCWSTR Key,
  71. DWORD Val
  72. );
  73. #define MultiSzAppendValW(buf,k,v) SETTRACKCOMMENT(BOOL,"MultiSzAppendValW",__FILE__,__LINE__)\
  74. RealMultiSzAppendValW(buf,k,v)\
  75. CLRTRACKCOMMENT
  76. BOOL
  77. RealMultiSzAppendStringA (
  78. PGROWBUFFER GrowBuf,
  79. PCSTR Key,
  80. PCSTR Val
  81. );
  82. #define MultiSzAppendStringA(buf,k,v) SETTRACKCOMMENT(BOOL,"MultiSzAppendStringA",__FILE__,__LINE__)\
  83. RealMultiSzAppendStringA(buf,k,v)\
  84. CLRTRACKCOMMENT
  85. BOOL
  86. RealMultiSzAppendStringW (
  87. PGROWBUFFER GrowBuf,
  88. PCWSTR Key,
  89. PCWSTR Val
  90. );
  91. #define MultiSzAppendStringW(buf,k,v) SETTRACKCOMMENT(BOOL,"MultiSzAppendStringW",__FILE__,__LINE__)\
  92. RealMultiSzAppendStringW(buf,k,v)\
  93. CLRTRACKCOMMENT
  94. BOOL
  95. RealGrowBufAppendDword (
  96. PGROWBUFFER GrowBuf,
  97. DWORD d
  98. );
  99. #define GrowBufAppendDword(buf,d) SETTRACKCOMMENT(BOOL,"GrowBufAppendDword",__FILE__,__LINE__)\
  100. RealGrowBufAppendDword(buf,d)\
  101. CLRTRACKCOMMENT
  102. BOOL
  103. RealGrowBufAppendStringA (
  104. PGROWBUFFER GrowBuf,
  105. PCSTR String
  106. );
  107. #define GrowBufAppendStringA(buf,str) SETTRACKCOMMENT(BOOL,"GrowBufAppendStringA",__FILE__,__LINE__)\
  108. RealGrowBufAppendStringA(buf,str)\
  109. CLRTRACKCOMMENT
  110. BOOL
  111. RealGrowBufAppendStringW (
  112. PGROWBUFFER GrowBuf,
  113. PCWSTR String
  114. );
  115. #define GrowBufAppendStringW(buf,str) SETTRACKCOMMENT(BOOL,"GrowBufAppendStringW",__FILE__,__LINE__)\
  116. RealGrowBufAppendStringW(buf,str)\
  117. CLRTRACKCOMMENT
  118. BOOL
  119. RealGrowBufAppendStringABA (
  120. PGROWBUFFER GrowBuf,
  121. PCSTR Start,
  122. PCSTR EndPlusOne
  123. );
  124. #define GrowBufAppendStringABA(buf,a,b) SETTRACKCOMMENT(BOOL,"GrowBufAppendStringABA",__FILE__,__LINE__)\
  125. RealGrowBufAppendStringABA(buf,a,b)\
  126. CLRTRACKCOMMENT
  127. BOOL
  128. RealGrowBufAppendStringABW (
  129. PGROWBUFFER GrowBuf,
  130. PCWSTR Start,
  131. PCWSTR EndPlusOne
  132. );
  133. #define GrowBufAppendStringABW(buf,a,b) SETTRACKCOMMENT(BOOL,"GrowBufAppendStringABW",__FILE__,__LINE__)\
  134. RealGrowBufAppendStringABW(buf,a,b)\
  135. CLRTRACKCOMMENT
  136. BOOL
  137. RealGrowBufCopyStringA (
  138. PGROWBUFFER GrowBuf,
  139. PCSTR String
  140. );
  141. #define GrowBufCopyStringA(buf,str) SETTRACKCOMMENT(BOOL,"GrowBufCopyStringA",__FILE__,__LINE__)\
  142. RealGrowBufCopyStringA(buf,str)\
  143. CLRTRACKCOMMENT
  144. BOOL
  145. RealGrowBufCopyStringW (
  146. PGROWBUFFER GrowBuf,
  147. PCWSTR String
  148. );
  149. #define GrowBufCopyStringW(buf,str) SETTRACKCOMMENT(BOOL,"GrowBufCopyStringW",__FILE__,__LINE__)\
  150. RealGrowBufCopyStringW(buf,str)\
  151. CLRTRACKCOMMENT
  152. #ifdef UNICODE
  153. #define MultiSzAppend MultiSzAppendW
  154. #define MultiSzAppendVal MultiSzAppendValW
  155. #define MultiSzAppendString MultiSzAppendStringW
  156. #define GrowBufAppendString GrowBufAppendStringW
  157. #define GrowBufAppendStringAB GrowBufAppendStringABW
  158. #define GrowBufCopyString GrowBufCopyStringW
  159. #else
  160. #define MultiSzAppend MultiSzAppendA
  161. #define MultiSzAppendVal MultiSzAppendValA
  162. #define MultiSzAppendString MultiSzAppendStringA
  163. #define GrowBufAppendString GrowBufAppendStringA
  164. #define GrowBufAppendStringAB GrowBufAppendStringABA
  165. #define GrowBufCopyString GrowBufCopyStringA
  166. #endif