At 2:30 PM +0200 06/28/00, Lurenzel wrote:
>    A MemPtr and a VoidPtr is simply a pointer or and address of a location
>in memory.  For example the address of a database record.

Nope.  A voidPtr is one of these, but that's old school.  You should just
use void * instead.  In technical terms, VoidPtr is a "lame" and "useless"
typedef. :-)

A MemPtr is a special pointer, namely one to the beginning of a memory
manager chunk.  That is, a MemPtr references memory allocated with
MemPtrNew or retrieved from a handle with MemHandleLock.  Pointers to other
parts of memory are just "plain" pointers.

Confusion in this area leads to a common class of memory-related errors
such as freeing chunks too early or trying to reference data in unlocked
chunks, and clearing this up is the primary reason for the renaming we did
in OS 3.5!

>    The pointer to the record can change and the operating system will
>change the pointer to it appropriately. But  it is allways stored in the
>SAME location in memory as the original pointer. So the operating system
>returns the pointer (which doesn't change) to the place in memory where the
>updated pointer is stored. This is a handle.

Technically, this is a MemHandle.  A handle (generic) is just a pointer to
a pointer, generally intended to solve the problem you describe: being able
to move the pointer without losing touch with it.  MemHandles, however, and
NOT simply pointers to pointers... they are encoded to help prevent
accidental dereferencing.  You must use MemHandleLock to retrieve the
MemPtr from a MemHandle.

See http://oasis.palm.com/dev/kb/papers/1145.cfm for more details about
memory management in Palm OS.

                                --Bob



-- 
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