Thanks for the explaination. I would be using it immediately after that. As
Steve said in another reply, it can still be risky.
I was thinking about a cheap way to do the thing using a function without
having lots of UnLock and Release floating around.
Well, I think it is better to be safe than sorry.
Thanks.
Max
--- Joe <[EMAIL PROTECTED]> wrote:
> --- 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.
=====
http://www.weirdwww.com/
__________________________________________________
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/