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.

160 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1999-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgheap.hxx
  6. Abstract:
  7. Debug heap header file
  8. Author:
  9. Steve Kiraly (SteveKi) 6-Feb-1999
  10. Revision History:
  11. --*/
  12. #ifndef _DBGHEAP_HXX_
  13. #define _DBGHEAP_HXX_
  14. DEBUG_NS_BEGIN
  15. class TDebugHeap
  16. {
  17. public:
  18. enum eConstants
  19. {
  20. kDefaultHeapSize = 64*1024,
  21. kDefaultHeapGranularity = sizeof(UINT_PTR),
  22. };
  23. enum eBlockState
  24. {
  25. kFree = 0,
  26. kInUse = 1,
  27. };
  28. struct BlockHeader
  29. {
  30. BlockHeader *pNext;
  31. SIZE_T uSize;
  32. eBlockState eStatus;
  33. };
  34. //
  35. // Function type for heap walk routine.
  36. //
  37. typedef BOOL(*pfHeapEnumProc)( BlockHeader *pBlock, PVOID pRefData );
  38. TDebugHeap::
  39. TDebugHeap(
  40. VOID
  41. );
  42. TDebugHeap::
  43. ~TDebugHeap(
  44. VOID
  45. );
  46. BOOL
  47. TDebugHeap::
  48. Valid(
  49. VOID
  50. ) const;
  51. VOID
  52. TDebugHeap::
  53. Initialize(
  54. VOID
  55. );
  56. VOID
  57. TDebugHeap::
  58. Destroy(
  59. VOID
  60. );
  61. PVOID
  62. TDebugHeap::
  63. Malloc(
  64. IN SIZE_T uSize
  65. );
  66. VOID
  67. TDebugHeap::
  68. Free(
  69. IN PVOID pData
  70. );
  71. BOOL
  72. TDebugHeap::
  73. Walk(
  74. IN pfHeapEnumProc pEnumProc,
  75. IN PVOID pRefData
  76. );
  77. private:
  78. //
  79. // Copying and assignment are not defined.
  80. //
  81. TDebugHeap::
  82. TDebugHeap(
  83. const TDebugHeap &rhs
  84. );
  85. const TDebugHeap &
  86. TDebugHeap::
  87. operator=(
  88. const TDebugHeap &rhs
  89. );
  90. static
  91. BOOL
  92. TDebugHeap::
  93. DefaultHeapEnumProc(
  94. IN BlockHeader *pBlockHeader,
  95. IN PVOID pRefData
  96. );
  97. VOID
  98. TDebugHeap::
  99. SplitBlock(
  100. IN BlockHeader *pBlock,
  101. IN SIZE_T size
  102. );
  103. VOID
  104. TDebugHeap::
  105. Coalesce(
  106. IN BlockHeader *pBlock
  107. );
  108. SIZE_T
  109. TDebugHeap::
  110. RoundUpToGranularity(
  111. IN SIZE_T uValue
  112. ) const;
  113. VOID
  114. TDebugHeap::
  115. InitalizeClassMembers(
  116. VOID
  117. );
  118. BOOL m_bValid;
  119. BlockHeader *m_pHeap;
  120. HANDLE m_hHeap;
  121. SIZE_T m_uSize;
  122. UINT m_uGranularity;
  123. };
  124. DEBUG_NS_END
  125. #endif // _DBGHEAP_HXX_