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.

53 lines
932 B

  1. /*
  2. * Fixed-Size Small Block Allocator
  3. */
  4. #ifndef DUI_BASE_SBALLOC_H_INCLUDED
  5. #define DUI_BASE_SBALLOC_H_INCLUDED
  6. #pragma once
  7. #include "duialloc.h"
  8. namespace DirectUI
  9. {
  10. #define SBALLOC_FILLCHAR 0xFE
  11. struct ISBLeak // Leak detector, not ref counted
  12. {
  13. virtual void AllocLeak(void* pBlock) = 0;
  14. };
  15. struct SBSection
  16. {
  17. SBSection* pNext;
  18. BYTE* pData;
  19. };
  20. class SBAlloc
  21. {
  22. public:
  23. static HRESULT Create(UINT uBlockSize, UINT uBlocksPerSection, ISBLeak* pisbLeak, SBAlloc** ppSBA);
  24. void Destroy();
  25. void* Alloc();
  26. void Free(void* pBlock);
  27. SBAlloc() { }
  28. virtual ~SBAlloc();
  29. private:
  30. bool _FillStack();
  31. UINT _uBlockSize;
  32. UINT _uBlocksPerSection;
  33. SBSection* _pSections;
  34. BYTE** _ppStack; // Free block cache
  35. int _dStackPtr;
  36. ISBLeak* _pisbLeak;
  37. };
  38. } // namespace DirectUI
  39. #endif // DUI_BASE_SBALLOC_H_INCLUDED