I would like some confirmation about this questions:
When do I need to increase an objects reference count by an implicit call to AddRef?
Until now I think at:
IUnknown -> QueryInterface
IClassFactory -> CreateInstance
What about Get / Set functions inside interfaces, like IOLEObject -> GetClientSite, which return
an interface, should these also call AddRef inside GetClientSite?
When do I need to increase an objects reference count by an implicit call to AddRef?
Until now I think at:
IUnknown -> QueryInterface
IClassFactory -> CreateInstance
What about Get / Set functions inside interfaces, like IOLEObject -> GetClientSite, which return
an interface, should these also call AddRef inside GetClientSite?
if you return a pointer you should do AddRef first (as in GetClientSite)
If a pointer is supplied as a parameter, the called function has to do the AddRef (as in SetClientSite)
If a pointer is supplied as a parameter, the called function has to do the AddRef (as in SetClientSite)
thanks, I will review my interfaces.
I had a problem, that occured since I free allocated object structures inside IUnknown->Release if reference count is zero. This was no problem with Win95, but with Win2000, Win2K seems to handle
the reference counters more correctly, so if I miss one add, the count gets wrong and I free the object too early, so Windows tries to call methods on an already freed object.
I had a problem, that occured since I free allocated object structures inside IUnknown->Release if reference count is zero. This was no problem with Win95, but with Win2000, Win2K seems to handle
the reference counters more correctly, so if I miss one add, the count gets wrong and I free the object too early, so Windows tries to call methods on an already freed object.
Hi beaster,
that's really one of the most common and time consuming problems. In debug versions of my programs I "clear" memory of heap item with AAh before freeing it. Thats useful for Win9x, as you have already mentioned.
Japheth
that's really one of the most common and time consuming problems. In debug versions of my programs I "clear" memory of heap item with AAh before freeing it. Thats useful for Win9x, as you have already mentioned.
Japheth