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.

221 lines
5.4 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. } GROWBUFFER;
  21. #define INIT_GROWBUFFER {NULL,0,0,0,0}
  22. PBYTE
  23. RealGbGrow (
  24. IN OUT PGROWBUFFER GrowBuf,
  25. IN DWORD SpaceNeeded
  26. );
  27. #define GbGrow(buf,size) TRACK_BEGIN(PBYTE, GbGrow)\
  28. RealGbGrow(buf,size)\
  29. TRACK_END()
  30. VOID
  31. GbFree (
  32. IN PGROWBUFFER GrowBuf
  33. );
  34. BOOL
  35. RealGbMultiSzAppendA (
  36. PGROWBUFFER GrowBuf,
  37. PCSTR String
  38. );
  39. #define GbMultiSzAppendA(buf,str) TRACK_BEGIN(BOOL, GbMultiSzAppendA)\
  40. RealGbMultiSzAppendA(buf,str)\
  41. TRACK_END()
  42. BOOL
  43. RealGbMultiSzAppendW (
  44. PGROWBUFFER GrowBuf,
  45. PCWSTR String
  46. );
  47. #define GbMultiSzAppendW(buf,str) TRACK_BEGIN(BOOL, GbMultiSzAppendW)\
  48. RealGbMultiSzAppendW(buf,str)\
  49. TRACK_END()
  50. BOOL
  51. RealGbMultiSzAppendValA (
  52. PGROWBUFFER GrowBuf,
  53. PCSTR Key,
  54. DWORD Val
  55. );
  56. #define GbMultiSzAppendValA(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendValA)\
  57. RealGbMultiSzAppendValA(buf,k,v)\
  58. TRACK_END()
  59. BOOL
  60. RealGbMultiSzAppendValW (
  61. PGROWBUFFER GrowBuf,
  62. PCWSTR Key,
  63. DWORD Val
  64. );
  65. #define GbMultiSzAppendValW(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendValW)\
  66. RealGbMultiSzAppendValW(buf,k,v)\
  67. TRACK_END()
  68. BOOL
  69. RealGbMultiSzAppendStringA (
  70. PGROWBUFFER GrowBuf,
  71. PCSTR Key,
  72. PCSTR Val
  73. );
  74. #define GbMultiSzAppendStringA(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendStringA)\
  75. RealGbMultiSzAppendStringA(buf,k,v)\
  76. TRACK_END()
  77. BOOL
  78. RealGbMultiSzAppendStringW (
  79. PGROWBUFFER GrowBuf,
  80. PCWSTR Key,
  81. PCWSTR Val
  82. );
  83. #define GbMultiSzAppendStringW(buf,k,v) TRACK_BEGIN(BOOL, GbMultiSzAppendStringW)\
  84. RealGbMultiSzAppendStringW(buf,k,v)\
  85. TRACK_END()
  86. BOOL
  87. RealGbAppendDword (
  88. PGROWBUFFER GrowBuf,
  89. DWORD d
  90. );
  91. #define GbAppendDword(buf,d) TRACK_BEGIN(BOOL, GbAppendDword)\
  92. RealGbAppendDword(buf,d)\
  93. TRACK_END()
  94. BOOL
  95. RealGbAppendPvoid (
  96. PGROWBUFFER GrowBuf,
  97. PCVOID p
  98. );
  99. #define GbAppendPvoid(buf,p) TRACK_BEGIN(BOOL, GbAppendPvoid)\
  100. RealGbAppendPvoid(buf,p)\
  101. TRACK_END()
  102. BOOL
  103. RealGbAppendStringA (
  104. PGROWBUFFER GrowBuf,
  105. PCSTR String
  106. );
  107. #define GbAppendStringA(buf,str) TRACK_BEGIN(BOOL, GbAppendStringA)\
  108. RealGbAppendStringA(buf,str)\
  109. TRACK_END()
  110. BOOL
  111. RealGbAppendStringW (
  112. PGROWBUFFER GrowBuf,
  113. PCWSTR String
  114. );
  115. #define GbAppendStringW(buf,str) TRACK_BEGIN(BOOL, GbAppendStringW)\
  116. RealGbAppendStringW(buf,str)\
  117. TRACK_END()
  118. BOOL
  119. RealGbAppendStringABA (
  120. PGROWBUFFER GrowBuf,
  121. PCSTR Start,
  122. PCSTR EndPlusOne
  123. );
  124. #define GbAppendStringABA(buf,a,b) TRACK_BEGIN(BOOL, GbAppendStringABA)\
  125. RealGbAppendStringABA(buf,a,b)\
  126. TRACK_END()
  127. BOOL
  128. RealGbAppendStringABW (
  129. PGROWBUFFER GrowBuf,
  130. PCWSTR Start,
  131. PCWSTR EndPlusOne
  132. );
  133. #define GbAppendStringABW(buf,a,b) TRACK_BEGIN(BOOL, GbAppendStringABW)\
  134. RealGbAppendStringABW(buf,a,b)\
  135. TRACK_END()
  136. BOOL
  137. RealGbCopyStringA (
  138. PGROWBUFFER GrowBuf,
  139. PCSTR String
  140. );
  141. #define GbCopyStringA(buf,str) TRACK_BEGIN(BOOL, GbCopyStringA)\
  142. RealGbCopyStringA(buf,str)\
  143. TRACK_END()
  144. BOOL
  145. RealGbCopyStringW (
  146. PGROWBUFFER GrowBuf,
  147. PCWSTR String
  148. );
  149. #define GbCopyStringW(buf,str) TRACK_BEGIN(BOOL, GbCopyStringW)\
  150. RealGbCopyStringW(buf,str)\
  151. TRACK_END()
  152. #ifdef UNICODE
  153. #define GbMultiSzAppend GbMultiSzAppendW
  154. #define GbMultiSzAppendVal GbMultiSzAppendValW
  155. #define GbMultiSzAppendString GbMultiSzAppendStringW
  156. #define GbAppendString GbAppendStringW
  157. #define GbAppendStringAB GbAppendStringABW
  158. #define GbCopyString GbCopyStringW
  159. #else
  160. #define GbMultiSzAppend GbMultiSzAppendA
  161. #define GbMultiSzAppendVal GbMultiSzAppendValA
  162. #define GbMultiSzAppendString GbMultiSzAppendStringA
  163. #define GbAppendString GbAppendStringA
  164. #define GbAppendStringAB GbAppendStringABA
  165. #define GbCopyString GbCopyStringA
  166. #endif