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.

158 lines
3.5 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. COWBLOB.INL
  5. History:
  6. --*/
  7. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. //
  9. // Constructor for the blob. Set the current size to zero.
  10. //
  11. //-----------------------------------------------------------------------------
  12. inline
  13. CLocCOWBlob::CLocCOWBlob()
  14. {
  15. m_pBuffer = NULL;
  16. m_WriteCount = 0;
  17. m_uiGrowSize = m_uiDefaultGrowSize;
  18. DEBUGONLY(++m_UsageCounter);
  19. }
  20. #ifdef LTASSERT_ACTIVE
  21. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22. //
  23. // Returns the number of outstanding GetPointer()'s there are.
  24. // DEBUGONLY method!
  25. //
  26. //-----------------------------------------------------------------------------
  27. inline
  28. UINT
  29. CLocCOWBlob::GetWriteCount(void)
  30. const
  31. {
  32. return m_WriteCount;
  33. }
  34. #endif // _DEBUG
  35. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  36. //
  37. // Sets the granularity for memory allocations. Memory will always be
  38. // allocated in amounts that are a multiple of the GrowSize. This can be
  39. // useful if you are making small incremental reallocs - by setting a larger
  40. // grow size, you will allocate memory less often (but some may end up
  41. // being unused).
  42. //
  43. //-----------------------------------------------------------------------------
  44. inline
  45. void
  46. CLocCOWBlob::SetGrowSize(
  47. UINT uiGrowSize)
  48. {
  49. LTASSERT(uiGrowSize != 0);
  50. if (uiGrowSize == 0)
  51. {
  52. m_uiGrowSize = m_uiDefaultGrowSize;
  53. }
  54. else
  55. {
  56. m_uiGrowSize = uiGrowSize;
  57. }
  58. }
  59. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  60. //
  61. // Release a writable pointer. GetPointer and ReleasePointer should be
  62. // paired.
  63. //
  64. //-----------------------------------------------------------------------------
  65. inline
  66. void
  67. CLocCOWBlob::ReleasePointer(void)
  68. {
  69. LTASSERT(m_WriteCount != 0);
  70. if (m_WriteCount != 0)
  71. {
  72. m_WriteCount--;
  73. }
  74. }
  75. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  76. //
  77. // Return a read only pointer to storage.
  78. //
  79. //-----------------------------------------------------------------------------
  80. inline
  81. CLocCOWBlob::operator const void *(void)
  82. const
  83. {
  84. return DataPointer();
  85. }
  86. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  87. //
  88. // Destructor. Just detaches this blob from the user memory.
  89. //
  90. //-----------------------------------------------------------------------------
  91. inline
  92. CLocCOWBlob::~CLocCOWBlob()
  93. {
  94. DEBUGONLY(CLocCOWBlob::AssertValid());
  95. Detach();
  96. DEBUGONLY(--m_UsageCounter);
  97. }
  98. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  99. //
  100. // Is the data of this blob NOT equal to the data in the given blob?
  101. //
  102. //-----------------------------------------------------------------------------
  103. inline
  104. int //TRUE if both blobs are NOT identical
  105. CLocCOWBlob::operator!=(
  106. const CLocCOWBlob & SourceBlob)
  107. const
  108. {
  109. return !Compare(SourceBlob);
  110. }
  111. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  112. //
  113. // Is the data of this blob IS equal to the data in the given blob?
  114. //
  115. //-----------------------------------------------------------------------------
  116. inline
  117. int //TRUE if both blobs ARE identical
  118. CLocCOWBlob::operator==(
  119. const CLocCOWBlob & SourceBlob)
  120. const
  121. {
  122. return Compare(SourceBlob);
  123. }