Fredrik Jagenheim wrote in message <9776@palm-dev-forum>...
>
>Apart from the fact that the latter is easier and less error prone.
>I suppose there's some limitations on the Pointer way, but can't seem to
>find it. It seems, according to the docs, that I can do everything I
could've
>done with the Handle I could do with the Pointer... So what's the catch?
A locked pointer can not be moved by the memory management
routines. Within one subroutine, MemPtrNew/MemPtrFree is
probably ok -- but if you want to use the data throughout your
program you should use a handle so that it can be unlocked
(and therefore available to be relocated) by the OS when it
is not actually in use by one of your routines.
>Also, what's 'MemPtrUnlock' good for? I can't seem to find the
corresponding
>'MemPtrLock' either. Is MemPtrUnlock for Pointers I've received from
>MemHandleLock? If so, why is it there? If I no longer have the Handle I
>can't see the use in Unlocking, and therefor losing, the Pointer...
MemPtrUnlock is there to encourage poor programming practices.
Yes, it is there to be able to unlock a pointer you obtained by using
MemHandleLock. And yes, you should still have the handle around.
Even if you don't, there is an API routine to recover the handle from
a pointer. MemPtrUnlock breaks the symmetry that is important
for keeping track of proper use of New/Free pairs ... and now that
you mention it, it does seem kind of pointless since you can't even
free it after unlocking it with just the pointer ...
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi/sec: not just a good idea, it's the LAW!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html