Theos PowerBasic Museum 2017

Archive => Discussion - Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Topic started by: Edwin Knoppert on September 10, 2009, 10:44:28 AM

Title: Object from pointer - addref?
Post by: Edwin Knoppert on September 10, 2009, 10:44:28 AM
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.

?
Title: Re: Object from pointer - addref?
Post by: José Roca on September 10, 2009, 04:16:34 PM
 
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
Title: Re: Object from pointer - addref?
Post by: Edwin Knoppert on September 10, 2009, 04:30:41 PM
Thank you, clear enough.
:0