Hi,

in mozilla source I found some code which goes essentially as follows

class nsFunc : public nsIStreamListener {
  public:
    NS_DECL_ISUPPORTS
    NS_DECL_NSISTREAMLISTENER
}

NS_IMPL_ISUPPORTS1(nsFunc, nsIStreamListener)

nsFunc::OnStopRunningUrl() {
  Release();
  return Bla();
}

Bar(nsIStreamListener *aListener);

Foo () {
  nsFunc *tmp = new nsFunc;
  NS_IF_ADDREF(tmp);
  Bar(tmp);
}

When is the instance of nsFunc destroyed? I'm fine with tmp->Release() from
outside of nsFunc, but from within? What if it's releasing the last
reference?

Regards,
Rolf
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to