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.

84 lines
1.8 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: LUnknown.inl
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. //
  8. //
  9. //-----------------------------------------------------------------------------
  10. //*****************************************************************************
  11. //
  12. // CLUnknown Constructions / Destruction
  13. //
  14. //*****************************************************************************
  15. ///////////////////////////////////////////////////////////////////////////////
  16. inline
  17. CLUnknown::CLUnknown(
  18. IUnknown * pParent
  19. )
  20. {
  21. LTASSERT(pParent != NULL);
  22. m_ulRef = 0;
  23. m_pParent = pParent;
  24. m_pParent->AddRef();
  25. // AddRef(); // Don't AddRef() itself. The caller is expected to do this
  26. }
  27. ///////////////////////////////////////////////////////////////////////////////
  28. inline
  29. CLUnknown::~CLUnknown()
  30. {
  31. LTASSERT(m_ulRef == 0);
  32. LTASSERT(m_pParent != NULL);
  33. m_pParent->Release();
  34. }
  35. //*****************************************************************************
  36. //
  37. // CLUnknown Operations
  38. //
  39. //*****************************************************************************
  40. ///////////////////////////////////////////////////////////////////////////////
  41. inline
  42. ULONG
  43. CLUnknown::AddRef()
  44. {
  45. return ++m_ulRef;
  46. }
  47. ///////////////////////////////////////////////////////////////////////////////
  48. inline
  49. ULONG
  50. CLUnknown::Release()
  51. {
  52. LTASSERT(m_ulRef > 0);
  53. if (--m_ulRef == 0)
  54. {
  55. delete this;
  56. return 0;
  57. }
  58. return m_ulRef;
  59. }
  60. ///////////////////////////////////////////////////////////////////////////////
  61. inline
  62. HRESULT
  63. CLUnknown::QueryInterface(REFIID iid, LPVOID * ppvObject)
  64. {
  65. LTASSERT(ppvObject != NULL);
  66. return m_pParent->QueryInterface(iid, ppvObject);
  67. }