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.

147 lines
2.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: vect.hxx
  7. //
  8. // Contents: Vector common types
  9. //
  10. // Classes: CVectBits -- Bit fields for vectors
  11. //
  12. //--------------------------------------------------------------------------
  13. #ifndef __VECT_HXX__
  14. #define __VECT_HXX__
  15. #include <malloc.h>
  16. #include "page.hxx"
  17. //+-------------------------------------------------------------------------
  18. //
  19. // Class: CVectBits (vb)
  20. //
  21. // Purpose: Structure for Vector flags.
  22. //
  23. // Interface:
  24. //
  25. // Notes:
  26. //
  27. //--------------------------------------------------------------------------
  28. struct CVectBits
  29. {
  30. BYTE full:1;
  31. USHORT firstfree;
  32. inline CVectBits();
  33. };
  34. //+-------------------------------------------------------------------------
  35. //
  36. // Method: CVectBits::CVectBits, public
  37. //
  38. // Synopsis: CVectBits default constructor.
  39. //
  40. // Notes:
  41. //
  42. //--------------------------------------------------------------------------
  43. inline CVectBits::CVectBits()
  44. {
  45. full = 0;
  46. firstfree = 0;
  47. }
  48. inline CVectBits * GetNewVectBits(ULONG ulSize)
  49. {
  50. msfAssert(ulSize > 0);
  51. CVectBits *pfb = NULL;
  52. if (ulSize <= (_HEAP_MAXREQ / sizeof(CVectBits)))
  53. {
  54. pfb = new CVectBits[(MAXINDEXTYPE)ulSize];
  55. }
  56. return pfb;
  57. }
  58. //+-------------------------------------------------------------------------
  59. //
  60. // Class: CPagedVector (pv)
  61. //
  62. // Purpose: *Finish This*
  63. //
  64. // Interface:
  65. //
  66. // Notes:
  67. //
  68. //--------------------------------------------------------------------------
  69. class CPagedVector
  70. {
  71. public:
  72. inline CPagedVector(const SID sid);
  73. SCODE Init(CMStream *pms, ULONG ulSize);
  74. ~CPagedVector();
  75. void Empty(void);
  76. SCODE Resize(ULONG ulSize);
  77. SCODE Flush(void);
  78. SCODE GetTable(const ULONG iTable, DWORD dwFlags, void **ppmp);
  79. inline void ReleaseTable(const ULONG iTable);
  80. inline void SetSect(const ULONG iTable, const SECT sect);
  81. inline CVectBits * GetBits(const ULONG iTable);
  82. inline void ResetBits(void);
  83. SCODE SetDirty(ULONG iTable);
  84. inline void ResetDirty(ULONG iTable);
  85. inline void FreeTable(ULONG iTable);
  86. inline CMStream * GetParent(void) const;
  87. inline void SetParent(CMStream *pms);
  88. private:
  89. CMSFPageTable * _pmpt;
  90. const SID _sid;
  91. ULONG _ulSize; // Amount in use
  92. ULONG _ulAllocSize; // Amount allocated
  93. CMStream *_pmsParent;
  94. CMSFPage **_amp;
  95. CVectBits *_avb;
  96. #ifdef _MSC_VER
  97. #pragma warning(disable:4512)
  98. // since there is a const member, there should be no assignment operator
  99. #endif // _MSC_VER
  100. };
  101. #ifdef _MSC_VER
  102. #pragma warning(default:4512)
  103. #endif // _MSC_VER
  104. inline CPagedVector::CPagedVector(const SID sid)
  105. : _sid(sid),
  106. _pmpt(NULL),
  107. _amp(NULL),
  108. _avb(NULL),
  109. _pmsParent(NULL)
  110. {
  111. _ulSize = 0;
  112. _ulAllocSize = 0;
  113. }
  114. #endif //__VECT_HXX__