TypeLib containment refcounting

Ove Kaaven ovek at arcticnet.no
Tue Jun 17 09:38:55 CDT 2003

tir, 17.06.2003 kl. 14.55 skrev Mike Hearn:
> > > Well, unless you can call GetTypeInfoOfGuid twice and get two pointers to
> > > the same interface (maybe you can, i don't really know but that would seem
> > > unusual), I don't understand why this is wrong.
> > 
> > That is exactly what you can in the current typelib implementation. The
> > pointers will be the same, too. Whether you can in the real MS
> > implementation I'm not sure, but shouldn't matter, since the current
> > Wine implementation is what you're dealing with.
> Even so, as far as the users of these interfaces are concerned, they
> have to be properly reference counted which the app I'm dealing with,
> which is MS native code appears to do.
> So, is the problem here that I would be leaking references?

Yes, that's what I think Alexandre's point was. An app can use
GetTypeInfoOfGuid twice, the same typeinfo object would be returned in
both calls, you addref the typelib twice, the app can then release that
typeinfo twice, but with the result that the typeinfo is only destroyed
once, so the typelib would be only released once with your patch. So,
either addref the typelib only if the app does not already have
references to the typeinfo, or easier, always release the typelib in the
typeinfo's release whether or not it's the last reference (I'm not sure
you'd ever get to the last reference anyway because the typelib
structure keeps internal references to typeinfo objects too).

More information about the wine-devel mailing list