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.

86 lines
1.6 KiB

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