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.

65 lines
2.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: freelist.hxx
  7. //
  8. // Contents: CFreeList classes
  9. //
  10. // History: 07-Jul-94 BobDay Created
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifndef __FREELIST_HXX__
  14. #define __FREELIST_HXX__
  15. //+---------------------------------------------------------------------------
  16. //
  17. // Class: CFreeList (fl)
  18. //
  19. // Purpose: Implements a block allocator with replaceable underlying
  20. // memory strategies
  21. //
  22. // Interface: AllocElement - To allocate a proxy
  23. // ReleaseElement - To return an element to the free pool
  24. // AllocBlock - Callback for block allocation
  25. // GetElementNextPtr - Callback for list traversal
  26. //
  27. // Notes: At some point we might want to make this have one free list per
  28. // block. Then we would easily be able to tell which blocks have
  29. // all free elements within them and we able to be freed.
  30. //
  31. // History: 6-01-94 JohannP (Johann Posch) Created
  32. // 6-29-94 BobDay (Bob Day) Made list based
  33. //
  34. //----------------------------------------------------------------------------
  35. class CFreeList
  36. {
  37. public:
  38. DWORD AllocElement( void );
  39. void FreeElement( DWORD dwElement );
  40. void FreeMemoryBlocks( void );
  41. CFreeList( CMemoryModel *pmm,
  42. UINT iElementSize,
  43. UINT iElementsPerBlock,
  44. UINT iNextPtrOffset );
  45. private:
  46. CMemoryModel *m_pmm;
  47. DWORD m_iElementSize;
  48. DWORD m_iElementsPerBlock;
  49. DWORD m_iNextPtrOffset;
  50. DWORD m_dwHeadElement;
  51. DWORD m_dwTailElement;
  52. DWORD m_dwHeadBlock;
  53. };
  54. // Free lists
  55. extern CFreeList flFreeList16;
  56. extern CFreeList flFreeList32;
  57. extern CFreeList flHolderFreeList;
  58. extern CFreeList flRequestFreeList;
  59. #endif // #ifndef __FREELIST_HXX__