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.

152 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. hmem.hxx
  5. Abstract:
  6. The class HMEM is an implementation of the class MEM which uses the
  7. memory resources of the heap.
  8. After the first call to Acquire that succeeds, all successive calls
  9. will return the same memory that was returned by the first call
  10. provided that the size requested is within the bounds of the first call.
  11. The common buffer which was created upon the first successful call to
  12. Acquire will be available along with its size by calling GetBuf and
  13. QuerySize.
  14. Calling Destroy will put the object back in its initial state thus
  15. invalidating any pointers to its memory and enabling future calls
  16. to Acquire to succeed regardless of the size specicified.
  17. Author:
  18. Norbert P. Kusters (norbertk) 26-Nov-90
  19. --*/
  20. #if !defined(HMEM_DEFN)
  21. #define HMEM_DEFN
  22. #include "mem.hxx"
  23. DECLARE_CLASS( HMEM );
  24. class HMEM : public MEM {
  25. public:
  26. ULIB_EXPORT
  27. DECLARE_CONSTRUCTOR( HMEM );
  28. VIRTUAL
  29. ULIB_EXPORT
  30. ~HMEM(
  31. );
  32. NONVIRTUAL
  33. ULIB_EXPORT
  34. BOOLEAN
  35. Initialize(
  36. );
  37. VIRTUAL
  38. ULIB_EXPORT
  39. PVOID
  40. Acquire(
  41. IN ULONG Size,
  42. IN ULONG AlignmentMask DEFAULT 0
  43. );
  44. NONVIRTUAL
  45. PVOID
  46. GetBuf(
  47. ) CONST;
  48. NONVIRTUAL
  49. ULONG
  50. QuerySize(
  51. ) CONST;
  52. NONVIRTUAL
  53. ULIB_EXPORT
  54. BOOLEAN
  55. Resize(
  56. IN ULONG NewSize,
  57. IN ULONG AlignmentMask DEFAULT 0
  58. );
  59. private:
  60. NONVIRTUAL
  61. VOID
  62. Construct (
  63. );
  64. NONVIRTUAL
  65. VOID
  66. Destroy(
  67. );
  68. ULONG _size;
  69. PVOID _real_buf;
  70. PVOID _buf;
  71. };
  72. INLINE
  73. PVOID
  74. HMEM::GetBuf(
  75. ) CONST
  76. /*++
  77. Routine Description:
  78. This routine returns the memory that was previously 'Acquired'.
  79. Arguments:
  80. None.
  81. Return Value:
  82. A pointer to the beginning of the memory buffer.
  83. --*/
  84. {
  85. return _buf;
  86. }
  87. INLINE
  88. ULONG
  89. HMEM::QuerySize(
  90. ) CONST
  91. /*++
  92. Routine Description:
  93. This routine returns the size of the memory that was previously
  94. 'Acquired'.
  95. Arguments:
  96. None.
  97. Return Value:
  98. The size of the memory returned by 'GetBuf'.
  99. --*/
  100. {
  101. return _size;
  102. }
  103. #endif // HMEM_DEFN