[fdo-users] Memory management and FdoPtr

Gavin Cramer gavin.cramer at autodesk.com
Fri May 11 12:11:10 EDT 2012


Hi, Snehal.  In your use case is probably the most common for intermediate code that retrieves and also returns ref-counted FDO types.  The only special action to take is in the return statement, when it is necessary to increase the ref-count to preserve your method's "share" of object ownership on behalf of its caller.

FdoPtr<SomeFdoType> ret;
ret = CallSomeMethod();
return FDO_SAFE_ADDREF(ret.p);

Best wishes,
Gavin


From: fdo-users-bounces at lists.osgeo.org [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Snehal Joshi
Sent: Friday, May 11, 2012 12:03 PM
To: FDO Users Mail List
Subject: [fdo-users] Memory management and FdoPtr

Hi All,

I just started using FDO libraries, and have a question regarding memory management in FDO. I am confused about when to use FdoPtr and FDO_SAFE_ADDREF/FDO_SAFE_RELEASE.

Based on the information in the Developer's Guide, my understanding is that FdoPtr will take care of incrementing the reference count/release the object (provided the class implementes FdoIDisposable) - however, it'll call Release() as soon as the FdoPtr goes out of scope. So, within a function I write, if I wrap the return values of one of the FDO create/get methods in an FdoPtr, and return that FdoPtr as a function return value, it's a bad idea. Is that a valid assumption?

Thanks,
Snehal


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fdo-users/attachments/20120511/18d9b215/attachment.html


More information about the fdo-users mailing list