--- Max Bian wrote:
>
> MemPtr ptr;
> MemHandle h = DmGetResource(...);
> if(h) ptr = MemHandleLock(h);
> if(ptr) {
> MemHandleUnlock(h);
> DmReleaseResource(h);
> }
>
> Now if I use ptr immediately, it seems ok. I got what I want. How
> safe is it?
>
Are you really asking about using a pointer *after* unlocking the
memory it points to? This is not safe. Why would you even want to?
The whole purpose of allowing your app to "own" unlocked memory chunks
is so the OS can move that memory around if it needs to. If the OS
moves the memory after you unlock the handle, then your pointer isn't
going to be pointing to the right location. If you want to get access
to that memory after it moves, you have to do MemHandleLock() again to
get the correct pointer address. Similar logic should apply to
DmGetResource/DmReleaseResource.
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/