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

//-----------------------------------------------------------------------------
//
// File: LUnknown.inl
// Copyright (C) 1994-1997 Microsoft Corporation
// All rights reserved.
//
//
//
//-----------------------------------------------------------------------------
//*****************************************************************************
//
// CLUnknown Constructions / Destruction
//
//*****************************************************************************
///////////////////////////////////////////////////////////////////////////////
inline
CLUnknown::CLUnknown(
IUnknown * pParent
)
{
LTASSERT(pParent != NULL);
m_ulRef = 0;
m_pParent = pParent;
m_pParent->AddRef();
// AddRef(); // Don't AddRef() itself. The caller is expected to do this
}
///////////////////////////////////////////////////////////////////////////////
inline
CLUnknown::~CLUnknown()
{
LTASSERT(m_ulRef == 0);
LTASSERT(m_pParent != NULL);
m_pParent->Release();
}
//*****************************************************************************
//
// CLUnknown Operations
//
//*****************************************************************************
///////////////////////////////////////////////////////////////////////////////
inline
ULONG
CLUnknown::AddRef()
{
return ++m_ulRef;
}
///////////////////////////////////////////////////////////////////////////////
inline
ULONG
CLUnknown::Release()
{
LTASSERT(m_ulRef > 0);
if (--m_ulRef == 0)
{
delete this;
return 0;
}
return m_ulRef;
}
///////////////////////////////////////////////////////////////////////////////
inline
HRESULT
CLUnknown::QueryInterface(REFIID iid, LPVOID * ppvObject)
{
LTASSERT(ppvObject != NULL);
return m_pParent->QueryInterface(iid, ppvObject);
}