At 09:58 PM 10/29/2002 -0600, Ben Combee wrote:
At 19:09 2002-10-29 -0800, you wrote:
After calling VFSFileDBGetResource(), the documentation states that I should free the handle returned in the resHP argument using MemHandleFree().

However, the documentation for this function says that the handle is allocated in the _storage_ heap, which would imply it was allocated behind the scenes through the Data Manager, and should probably be deallocated using DmReleaseResource(). As I recall, one uses MemHandleFree() only on handles allocated in the dynamic heap.

Furthermore, MemHandleDataStorage( resHP ) returns true, confirming that resHP was allocated in the storage heap.

Is this a documentation bug, or am I missing something?
DmNewHandle allocates new chunks on the storage heap that aren't necessarily associated with any database. I would guess that the VFSFileDBGetResource call uses this. The correct way to free this memory is to use MemHandleFree, as noted in the documentation.
That makes sense. MemHandleFree() says it's used "to dispose of a movable chunk," but I was thrown off by the fact that MemHandleDataStorage( resHP) was returning true. I guess the moral is, you can have a handle that is in the storage heap which is not yet attached to any database, and for these, you deallocate with MemHandleFree(). This is precisely the kind of handle which VFSFileDBGetResource() probably returns. Thanks, Ben.

-Jeff Ishaq


--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/


Reply via email to