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.

148 lines
2.4 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. --*/
  18. #if !defined(HMEM_DEFN)
  19. #define HMEM_DEFN
  20. #include "mem.hxx"
  21. DECLARE_CLASS( HMEM );
  22. class HMEM : public MEM {
  23. public:
  24. ULIB_EXPORT
  25. DECLARE_CONSTRUCTOR( HMEM );
  26. VIRTUAL
  27. ULIB_EXPORT
  28. ~HMEM(
  29. );
  30. NONVIRTUAL
  31. ULIB_EXPORT
  32. BOOLEAN
  33. Initialize(
  34. );
  35. VIRTUAL
  36. ULIB_EXPORT
  37. PVOID
  38. Acquire(
  39. IN ULONG Size,
  40. IN ULONG AlignmentMask DEFAULT 0
  41. );
  42. NONVIRTUAL
  43. PVOID
  44. GetBuf(
  45. ) CONST;
  46. NONVIRTUAL
  47. ULONG
  48. QuerySize(
  49. ) CONST;
  50. NONVIRTUAL
  51. ULIB_EXPORT
  52. BOOLEAN
  53. Resize(
  54. IN ULONG NewSize,
  55. IN ULONG AlignmentMask DEFAULT 0
  56. );
  57. private:
  58. NONVIRTUAL
  59. VOID
  60. Construct (
  61. );
  62. NONVIRTUAL
  63. VOID
  64. Destroy(
  65. );
  66. ULONG _size;
  67. PVOID _real_buf;
  68. PVOID _buf;
  69. };
  70. INLINE
  71. PVOID
  72. HMEM::GetBuf(
  73. ) CONST
  74. /*++
  75. Routine Description:
  76. This routine returns the memory that was previously 'Acquired'.
  77. Arguments:
  78. None.
  79. Return Value:
  80. A pointer to the beginning of the memory buffer.
  81. --*/
  82. {
  83. return _buf;
  84. }
  85. INLINE
  86. ULONG
  87. HMEM::QuerySize(
  88. ) CONST
  89. /*++
  90. Routine Description:
  91. This routine returns the size of the memory that was previously
  92. 'Acquired'.
  93. Arguments:
  94. None.
  95. Return Value:
  96. The size of the memory returned by 'GetBuf'.
  97. --*/
  98. {
  99. return _size;
  100. }
  101. #endif // HMEM_DEFN