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.

92 lines
2.1 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: cowblob.h
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // Copy-On-Write (COW) blob class. Hold binary information, but only copies
  8. // the data when it's written to.
  9. //
  10. // Owner: MHotchin
  11. //
  12. // Code Review Status: Reviewed
  13. //
  14. //-----------------------------------------------------------------------------
  15. #ifndef COWBLOB_H
  16. #define COWBLOB_H
  17. class LTAPIENTRY CLocCOWBlob
  18. {
  19. public:
  20. CLocCOWBlob();
  21. CLocCOWBlob(const CLocCOWBlob &);
  22. void AssertValid(void) const;
  23. LTASSERTONLY(UINT GetWriteCount(void) const);
  24. UINT GetBlobSize(void) const;
  25. void SetBlobSize(UINT);
  26. void ReallocBlob(UINT);
  27. void SetGrowSize(UINT);
  28. void *GetPointer(void);
  29. void ReleasePointer(void);
  30. void SetBuffer(const void *, size_t);
  31. operator const void *(void) const;
  32. const CLocCOWBlob &operator=(const CLocCOWBlob &);
  33. void Serialize(CArchive &ar);
  34. void Load(CArchive &ar);
  35. void Store(CArchive &ar) const;
  36. ~CLocCOWBlob();
  37. // Comparison operators
  38. //
  39. NOTHROW int operator==(const CLocCOWBlob &) const;
  40. NOTHROW int operator!=(const CLocCOWBlob &) const;
  41. protected:
  42. private:
  43. typedef struct
  44. {
  45. DWORD RefCount;
  46. DWORD AllocSize;
  47. DWORD RequestedSize;
  48. } BlobHeader;
  49. NOTHROW void Attach(const CLocCOWBlob &);
  50. NOTHROW void Detach(void);
  51. NOTHROW void MakeWritable(void);
  52. NOTHROW BYTE * DataPointer(void) const;
  53. NOTHROW BlobHeader * GetBlobHeader(void);
  54. NOTHROW const BlobHeader * GetBlobHeader(void) const;
  55. NOTHROW DWORD & GetRefCount(void);
  56. NOTHROW DWORD GetAllocatedSize(void) const;
  57. NOTHROW DWORD GetRequestedSize(void) const;
  58. NOTHROW DWORD CalcNewSize(DWORD) const;
  59. BOOL Compare(const CLocCOWBlob &) const;
  60. BYTE *m_pBuffer;
  61. DWORD m_WriteCount;
  62. UINT m_uiGrowSize;
  63. static const UINT m_uiDefaultGrowSize;
  64. #ifdef _DEBUG
  65. static CCounter m_UsageCounter;
  66. void FillEndZone(void);
  67. void CheckEndZone();
  68. #endif
  69. };
  70. #if !defined(_DEBUG) || defined(IMPLEMENT)
  71. #include "cowblob.inl"
  72. #endif
  73. #endif // COWBLOB_H