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.

97 lines
3.0 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: RCBuff.h
  6. * Content: RefCount Buffers
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 01/12/00 mjn Created
  12. * 01/15/00 mjn Added GetBufferAddress and GetBufferSize
  13. * 01/31/00 mjn Allow user defined Alloc and Free
  14. ***************************************************************************/
  15. #ifndef __RCBUFF_H__
  16. #define __RCBUFF_H__
  17. #undef DPF_SUBCOMP
  18. #define DPF_SUBCOMP DN_SUBCOMP_COMMON
  19. //**********************************************************************
  20. // Constant definitions
  21. //**********************************************************************
  22. //**********************************************************************
  23. // Macro definitions
  24. //**********************************************************************
  25. //**********************************************************************
  26. // Structure definitions
  27. //**********************************************************************
  28. typedef PVOID (*PFNALLOC_REFCOUNT_BUFFER)(void *const,const DWORD);
  29. typedef void (*PFNFREE_REFCOUNT_BUFFER)(void *const,void *const);
  30. //**********************************************************************
  31. // Variable definitions
  32. //**********************************************************************
  33. //**********************************************************************
  34. // Function prototypes
  35. //**********************************************************************
  36. //**********************************************************************
  37. // Class prototypes
  38. //**********************************************************************
  39. // class for RefCount buffer
  40. class CRefCountBuffer
  41. {
  42. public:
  43. HRESULT Initialize( CFixedPool* pFPOOLRefCountBuffer, PFNALLOC_REFCOUNT_BUFFER pfnAlloc, PFNFREE_REFCOUNT_BUFFER pfnFree, const DWORD dwBufferSize);
  44. HRESULT SetBufferDesc( BYTE *const pBufferData, const DWORD dwBufferSize, PFNFREE_REFCOUNT_BUFFER pfnFree, void *const pvSpecialFree);
  45. static void FPMInitialize( void* pvItem, void* pvContext );
  46. void AddRef();
  47. void Release();
  48. #undef DPF_MODNAME
  49. #define DPF_MODNAME "BufferDescAddress"
  50. DPN_BUFFER_DESC *BufferDescAddress()
  51. {
  52. return(&m_dnBufferDesc);
  53. };
  54. #undef DPF_MODNAME
  55. #define DPF_MODNAME "GetBufferAddress"
  56. BYTE *GetBufferAddress()
  57. {
  58. return(m_dnBufferDesc.pBufferData);
  59. };
  60. #undef DPF_MODNAME
  61. #define DPF_MODNAME "GetBufferSize"
  62. DWORD GetBufferSize() const
  63. {
  64. return(m_dnBufferDesc.dwBufferSize);
  65. };
  66. private:
  67. LONG m_lRefCount;
  68. DPN_BUFFER_DESC m_dnBufferDesc; // Buffer
  69. CFixedPool* m_pFPOOLRefCountBuffer; // source FP of RefCountBuffers
  70. PFNFREE_REFCOUNT_BUFFER m_pfnFree; // Function to free buffer when released
  71. PFNALLOC_REFCOUNT_BUFFER m_pfnAlloc;
  72. PVOID m_pvContext; // Context provided to free buffer call
  73. PVOID m_pvSpecialFree;
  74. };
  75. #undef DPF_SUBCOMP
  76. #undef DPF_MODNAME
  77. #endif // __RCBUFF_H__