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.

211 lines
5.0 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. RealGbAppendDword (
  59. PGROWBUFFER GrowBuf,
  60. DWORD d
  61. );
  62. #define GbAppendDword(buf,d) TRACK_BEGIN(BOOL, GbAppendDword)\
  63. RealGbAppendDword(buf,d)\
  64. TRACK_END()
  65. BOOL
  66. RealGbAppendPvoid (
  67. PGROWBUFFER GrowBuf,
  68. PCVOID p
  69. );
  70. #define GbAppendPvoid(buf,p) TRACK_BEGIN(BOOL, GbAppendPvoid)\
  71. RealGbAppendPvoid(buf,p)\
  72. TRACK_END()
  73. BOOL
  74. RealGbAppendStringA (
  75. PGROWBUFFER GrowBuf,
  76. PCSTR String
  77. );
  78. #define GbAppendStringA(buf,str) TRACK_BEGIN(BOOL, GbAppendStringA)\
  79. RealGbAppendStringA(buf,str)\
  80. TRACK_END()
  81. BOOL
  82. RealGbAppendStringW (
  83. PGROWBUFFER GrowBuf,
  84. PCWSTR String
  85. );
  86. #define GbAppendStringW(buf,str) TRACK_BEGIN(BOOL, GbAppendStringW)\
  87. RealGbAppendStringW(buf,str)\
  88. TRACK_END()
  89. BOOL
  90. RealGbAppendStringABA (
  91. PGROWBUFFER GrowBuf,
  92. PCSTR Start,
  93. PCSTR EndPlusOne
  94. );
  95. #define GbAppendStringABA(buf,a,b) TRACK_BEGIN(BOOL, GbAppendStringABA)\
  96. RealGbAppendStringABA(buf,a,b)\
  97. TRACK_END()
  98. BOOL
  99. RealGbAppendStringABW (
  100. PGROWBUFFER GrowBuf,
  101. PCWSTR Start,
  102. PCWSTR EndPlusOne
  103. );
  104. #define GbAppendStringABW(buf,a,b) TRACK_BEGIN(BOOL, GbAppendStringABW)\
  105. RealGbAppendStringABW(buf,a,b)\
  106. TRACK_END()
  107. BOOL
  108. RealGbCopyStringA (
  109. PGROWBUFFER GrowBuf,
  110. PCSTR String
  111. );
  112. #define GbCopyStringA(buf,str) TRACK_BEGIN(BOOL, GbCopyStringA)\
  113. RealGbCopyStringA(buf,str)\
  114. TRACK_END()
  115. BOOL
  116. RealGbCopyStringW (
  117. PGROWBUFFER GrowBuf,
  118. PCWSTR String
  119. );
  120. #define GbCopyStringW(buf,str) TRACK_BEGIN(BOOL, GbCopyStringW)\
  121. RealGbCopyStringW(buf,str)\
  122. TRACK_END()
  123. BOOL
  124. RealGbCopyQuotedStringA (
  125. PGROWBUFFER GrowBuf,
  126. PCSTR String
  127. );
  128. #define GbCopyQuotedStringA(buf,str) TRACK_BEGIN(BOOL, GbCopyQuotedStringA)\
  129. RealGbCopyQuotedStringA(buf,str)\
  130. TRACK_END()
  131. BOOL
  132. RealGbCopyQuotedStringW (
  133. PGROWBUFFER GrowBuf,
  134. PCWSTR String
  135. );
  136. #define GbCopyQuotedStringW(buf,str) TRACK_BEGIN(BOOL, GbCopyQuotedStringW)\
  137. RealGbCopyQuotedStringW(buf,str)\
  138. TRACK_END()
  139. #ifdef DEBUG
  140. VOID
  141. GbDumpStatistics (
  142. VOID
  143. );
  144. #else
  145. #define GbDumpStatistics()
  146. #endif
  147. #ifdef UNICODE
  148. #define GbMultiSzAppend GbMultiSzAppendW
  149. #define GbAppendString GbAppendStringW
  150. #define GbAppendStringAB GbAppendStringABW
  151. #define GbCopyString GbCopyStringW
  152. #define GbCopyQuotedString GbCopyQuotedStringW
  153. #else
  154. #define GbMultiSzAppend GbMultiSzAppendA
  155. #define GbAppendString GbAppendStringA
  156. #define GbAppendStringAB GbAppendStringABA
  157. #define GbCopyString GbCopyStringA
  158. #define GbCopyQuotedString GbCopyQuotedStringA
  159. #endif