• Welcome to Theos PowerBasic Museum 2017.

Object from pointer - addref?

Started by Edwin Knoppert, September 10, 2009, 10:44:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Edwin Knoppert

The MSDN docs for SHGetMalloc() seems to be changed i guess.

My question is a general one, if i present a com object throught a function which returns a dword, the caller should release the object when done.
Now who's going to do the addref() in such a scenario?
For example the SHGetMalloc() seems to do the addref otherwise there may be no reference at all when exitting the SHGetMalloc() function isn't?

Imo all these kind of functions (as SHGetMalloc() for example) must call addref for you.

?

José Roca

#1
 
With Out parameters, including return values, the callee must return an AddRefed copy of the pointer, and the caller is responsible for releasing the pointer. Only the caller knows when it no longer needs the pointer.

Rules for Managing Reference Counts

http://msdn.microsoft.com/en-us/library/ms692481%28VS.85%29.aspx

Edwin Knoppert