Re: Who's in charge of AddRef'ing?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Roman Ryl... wrote:

CComPtr<IChild> m_pChild;

STDMETHOD(get_child)(IChild** ppChild)
{
if(!ppChild)
return E_POINTER;
*ppChild = CComPtr<IChild>(m_pChild).Detach(); // leave AddRef on
stack, in the out'ted variable

I'm not sure this is a good idea for a 'get' method. Detach() destroys
the existing reference (m_pChild) which CopyTo() does not.
.



Relevant Pages

  • Re: Whos in charge of AddRefing?
    ... STDMETHOD(IChild** ppChild) ... stack, in the out'ted variable ... Detach is called on a temporary CComPtr object ... The net effect is equivalent to CopyTo, ...
    (microsoft.public.vc.atl)
  • Re: Whos in charge of AddRefing?
    ... STDMETHOD(IChild** ppChild) ... stack, in the out'ted variable ... Detach is called on a temporary CComPtr object ... The net effect is equivalent to CopyTo, ...
    (microsoft.public.vc.atl)
  • Re: current panics when Netgear WG511T ejected
    ... just one dhcp-assigned unicast addr. ... Even if you have no multicast addresses explicitly configured by yourself or any application, the multicast code is always used on any system configured with INET. ... Because the hardware is being ejected, the netinet part of the stack won't see the detach first, but net will, and this is where the panic is happening. ...
    (freebsd-current)
  • Re: Whats the secmantics of IoDetachDevice?
    ... C's driver will have its FastIoDetachDevice callback called, ... and should detach and destroy C in this callback. ... then A is sure to be removed from the stack. ...
    (microsoft.public.development.device.drivers)
  • Re: Serial Upper Filter Driver Help Required
    ... You need to shutdown the stack to detach the driver. ... Maxim Shatskih, Windows DDK MVP ...
    (microsoft.public.development.device.drivers)