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.

183 lines
4.7 KiB

  1. /* TMemory2.h
  2. *
  3. * Copyright (c) 1994-1995 by DataBeam Corporation, Lexington, KY
  4. *
  5. * Abstract:
  6. * This is a memory class used to manage a memory buffer. During
  7. * instantiation, a buffer is allocated and a prepend value is passed in.
  8. * The prepend value is used during the Append() call. All Append() calls
  9. * are appended after the prepend value. A running length is also
  10. * maintained. This class is good to use if you are going to build up a
  11. * packet over time.
  12. *
  13. * If a packet overruns the max. buffer size, a new buffer is allocated and
  14. * used.
  15. *
  16. * Caveats:
  17. * None.
  18. *
  19. * Authors:
  20. * James W. Lawwill
  21. */
  22. #ifndef _TMEMORY2_
  23. #define _TMEMORY2_
  24. #define MAXIMUM_NUMBER_REALLOC_FAILURES 10
  25. typedef enum
  26. {
  27. TMEMORY_NO_ERROR,
  28. TMEMORY_NONFATAL_ERROR,
  29. TMEMORY_FATAL_ERROR,
  30. TMEMORY_NO_DATA
  31. }
  32. TMemoryError, * PTMemoryError;
  33. class TMemory
  34. {
  35. public:
  36. TMemory (
  37. ULong total_length,
  38. UShort prepend_space,
  39. PTMemoryError error);
  40. ~TMemory (
  41. Void);
  42. TMemoryError Append (
  43. HPUChar address,
  44. ULong length);
  45. TMemoryError GetMemory (
  46. HPUChar * address,
  47. FPULong length);
  48. Void Reset (
  49. Void);
  50. private:
  51. ULong Default_Buffer_Size;
  52. HPUChar Base_Buffer;
  53. HPUChar Auxiliary_Buffer;
  54. ULong Length;
  55. DBBoolean Auxiliary_Buffer_In_Use;
  56. UShort Prepend_Space;
  57. UShort Fatal_Error_Count;
  58. };
  59. typedef TMemory * PTMemory;
  60. #endif
  61. /*
  62. * Documentation for Public class members
  63. */
  64. /*
  65. * TMemory::TMemory (
  66. * ULong total_length,
  67. * UShort prepend_space,
  68. * PTMemoryError error);
  69. *
  70. * Functional Description:
  71. * This is the constructor for the TMemory class.
  72. *
  73. * Formal Parameters:
  74. * total_length (i) - Length of the default buffer
  75. * prepend_space (i) - Space to leave blank in the buffer
  76. * error (o) - Returns an error value
  77. *
  78. * Return Value:
  79. * None.
  80. *
  81. * Side Effects:
  82. * None.
  83. *
  84. * Caveats:
  85. * None.
  86. */
  87. /*
  88. * TMemory::TMemory (
  89. * Void)
  90. *
  91. * Functional Description:
  92. * This is the destructor for the object.
  93. *
  94. * Formal Parameters:
  95. * None.
  96. *
  97. * Return Value:
  98. * None.
  99. *
  100. * Side Effects:
  101. * None.
  102. *
  103. * Caveats:
  104. * None.
  105. */
  106. /*
  107. * TMemoryError TMemory::Append (
  108. * HPUChar address,
  109. * ULong length);
  110. *
  111. * Functional Description:
  112. * This function appends the buffer passed in to the internal buffer.
  113. *
  114. * Formal Parameters:
  115. * address (i) - Address of buffer
  116. * length (i) - Length of buffer
  117. *
  118. * Return Value:
  119. * TMEMORY_NO_ERROR - No error
  120. * TMEMORY_FATAL_ERROR - Fatal error occured, can't alloc a buffer
  121. * TMEMORY_NONFATAL_ERROR - Buffer was not copied but it was not a
  122. * fatal error
  123. *
  124. * Side Effects:
  125. * None.
  126. *
  127. * Caveats:
  128. * None.
  129. */
  130. /*
  131. * TMemoryError TMemory::GetMemory (
  132. * HPUChar * address,
  133. * FPULong length);
  134. *
  135. * Functional Description:
  136. * This function returns the address and used length of our internal buffer
  137. *
  138. * Formal Parameters:
  139. * address (o) - Address of our internal buffer
  140. * length (i) - Length of buffer
  141. *
  142. * Return Value:
  143. * TMEMORY_NO_ERROR - No error
  144. *
  145. * Side Effects:
  146. * None.
  147. *
  148. * Caveats:
  149. * None.
  150. */
  151. /*
  152. * Void TMemory::Reset (
  153. * Void)
  154. *
  155. * Functional Description:
  156. * This function resets the memory object. All data in the object is lost
  157. *
  158. * Formal Parameters:
  159. * None
  160. *
  161. * Return Value:
  162. * None
  163. *
  164. * Side Effects:
  165. * None.
  166. *
  167. * Caveats:
  168. * None.
  169. */