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.

113 lines
2.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: stalloc.hxx
  7. //
  8. // Contents: CStackAllocator
  9. //
  10. // History: 29-Sep-94 DrewB Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifndef __STALLOC_HXX__
  14. #define __STALLOC_HXX__
  15. //+---------------------------------------------------------------------------
  16. //
  17. // Struct: SStackMemTrace (smt)
  18. //
  19. // Purpose: Stack memory size/leak checking information
  20. //
  21. // History: 28-Apr-94 DrewB Created
  22. //
  23. //----------------------------------------------------------------------------
  24. #if DBG == 1
  25. struct SStackMemTrace
  26. {
  27. void *pvCaller;
  28. UINT cbSize;
  29. };
  30. #endif
  31. //+---------------------------------------------------------------------------
  32. //
  33. // Class: SStackRecord (sr)
  34. //
  35. // Purpose: Capture stack allocation state
  36. //
  37. // History: 28-Apr-94 DrewB Created
  38. //
  39. //----------------------------------------------------------------------------
  40. #if DBG == 1
  41. struct SStackRecord
  42. {
  43. DWORD dwStackPointer;
  44. DWORD dwThreadId;
  45. };
  46. #endif
  47. //+---------------------------------------------------------------------------
  48. //
  49. // Class: CStackAllocator (sa)
  50. //
  51. // Purpose: Abstract definition of a stack allocator with
  52. // replaceable underlying memory allocator
  53. //
  54. // History: 29-Sep-94 DrewB Created
  55. //
  56. //----------------------------------------------------------------------------
  57. class CStackAllocator
  58. {
  59. public:
  60. CStackAllocator(CMemoryModel *pmm,
  61. DWORD cbBlock,
  62. DWORD cbAlignment);
  63. ~CStackAllocator(void);
  64. DWORD Alloc(DWORD cb);
  65. void Free(DWORD dwMem, DWORD cb);
  66. #if DBG == 1
  67. void RecordState(SStackRecord *psr);
  68. void CheckState(SStackRecord *psr);
  69. #endif
  70. void Reset(void);
  71. CStackAllocator *GetNextAllocator(void)
  72. {
  73. return _psaNext;
  74. }
  75. void SetNextAllocator(CStackAllocator *psa)
  76. {
  77. _psaNext = psa;
  78. }
  79. BOOL GetActive(void)
  80. {
  81. return _fActive;
  82. }
  83. void SetActive(BOOL fActive)
  84. {
  85. _fActive = fActive;
  86. }
  87. private:
  88. DWORD _cbBlock;
  89. DWORD _cbAlignment;
  90. CMemoryModel *_pmm;
  91. DWORD _dwBlocks;
  92. DWORD _dwCurrent;
  93. DWORD _cbAvailable;
  94. CStackAllocator *_psaNext;
  95. BOOL _fActive;
  96. };
  97. #endif // #ifndef __STALLOC_HXX__