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.

66 lines
1.7 KiB

  1. /***************************************************************************\
  2. *
  3. * File: TempHelp.h
  4. *
  5. * Description:
  6. * TempHelp.h defines a "lightweight heap", designed to continuously grow
  7. * until all memory is freed. This is valuable as a temporary heap that can
  8. * be used to "collect" data and processed slightly later.
  9. *
  10. *
  11. * History:
  12. * 3/30/2000: JStall: Created
  13. *
  14. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  15. *
  16. \***************************************************************************/
  17. #if !defined(BASE__TempHeap_h__INCLUDED)
  18. #define BASE__TempHeap_h__INCLUDED
  19. #pragma once
  20. class TempHeap
  21. {
  22. // Construction
  23. public:
  24. TempHeap(int cbPageAlloc = 8000, int cbLargeThreshold = 512);
  25. inline ~TempHeap();
  26. inline void Destroy();
  27. // Operations
  28. public:
  29. void * Alloc(int cbAlloc);
  30. inline BOOL IsCompletelyFree() const;
  31. inline void Lock();
  32. inline void Unlock();
  33. // Implementation
  34. protected:
  35. void FreeAll(BOOL fComplete = FALSE);
  36. // Data
  37. protected:
  38. struct Page
  39. {
  40. Page * pNext;
  41. inline BYTE * GetData()
  42. {
  43. return (BYTE *) (((BYTE *) this) + sizeof(Page));
  44. }
  45. };
  46. long m_cLocks;
  47. BYTE * m_pbFree;
  48. Page * m_ppageCur;
  49. Page * m_ppageLarge;
  50. int m_cbFree; // Free space on current page
  51. int m_cbPageAlloc; // Allocation size of new pages
  52. int m_cbLargeThreshold; // Threshold for allocating large pages
  53. };
  54. #include "TempHeap.inl"
  55. #endif // BASE__TempHeap_h__INCLUDED