John,

It occurs to me that what you suggest has a subtle bug:



MemHandle h;
void *p;

h = MemHandleNew(100);
p = MemHandleLock(h);

// Use p for a while
// ...

MemPtrUnlock(p);
MemPtrFree(p);



By the time your reach MemPtrFree, p is invalid. You should never reference
a pointer after the associated handle has been unlocked because it may move
in memory.

Admittedly it's not very likely that the pointer will be moved if
MemPtrFree() immediately follows MemPtrUnlock, but it's still possible.

Bob Whiteman
Senior Software Engineer
Pico Communications

"John Leung" <[EMAIL PROTECTED]> wrote in message
news:74794@palm-dev-forum...
>
> For you second method, you'll still need to unlock the pointer with
>
> MemPtrUnlock(testPtr);



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

Reply via email to