Exemplo n.º 1
0
STDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()
{
    /* If the reference count drops to zero delete ourselves */

    LONG lRef = InterlockedDecrement( &m_cRef );
    ASSERT(lRef >= 0);

    DbgLog((LOG_MEMORY,3,TEXT("    Object %d ref-- = %d"),
	    m_dwCookie, m_cRef));
    if (lRef == 0) {

        // COM rules say we must protect against re-entrancy.
        // If we are an aggregator and we hold our own interfaces
        // on the aggregatee, the QI for these interfaces will
        // addref ourselves. So after doing the QI we must release
        // a ref count on ourselves. Then, before releasing the
        // private interface, we must addref ourselves. When we do
        // this from the destructor here it will result in the ref
        // count going to 1 and then back to 0 causing us to
        // re-enter the destructor. Hence we add an extra refcount here
        // once we know we will delete the object.
        // for an example aggregator see filgraph\distrib.cpp.

        m_cRef++;

        delete this;
        return ULONG(0);
    } else {
        return ourmax(ULONG(m_cRef), 1ul);
    }
}
Exemplo n.º 2
0
STDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()
{
 // If the reference count drops to zero delete ourselves.

 LONG lRef = InterlockedDecrement( (LONG*)&m_cRef );

 if (lRef == 0)
  {

   /* COM rules say we must protect against re-entrancy.
      If we are an aggregator and we hold our own interfaces
      on the aggregatee, the QI for these interfaces will
      addref ourselves. So after doing the QI we must release
      a ref count on ourselves. Then, before releasing the
      private interface, we must addref ourselves. When we do
      this from the destructor here it will result in the ref
      count going to 1 and then back to 0 causing us to
      re-enter the destructor. Hence we add an extra refcount here
      once we know we will delete the object.
      for an example aggregator see filgraph\distrib.cpp.*/

   m_cRef++;

   delete this;
   return ULONG(0);
  }
 else
  {
   return ourmax(ULONG(m_cRef), 1ul);
  }
}
Exemplo n.º 3
0
STDMETHODIMP_(ULONG) CUnknown::NonDelegatingAddRef()
{
    LONG lRef = InterlockedIncrement( &m_cRef );
    ASSERT(lRef > 0);
    DbgLog((LOG_MEMORY,3,TEXT("    Obj %d ref++ = %d"),
           m_dwCookie, m_cRef));
    return ourmax(ULONG(m_cRef), 1ul);
}
Exemplo n.º 4
0
STDMETHODIMP_(ULONG) CUnknown::NonDelegatingAddRef()
{
 LONG lRef = InterlockedIncrement((LONG*)&m_cRef );
 ASSERT(lRef > 0);
 return ourmax(ULONG(m_cRef), 1ul);
}