Bob,

Thanks for the response, but if the handle is LOCKED, then a compaction
should not move memory. A MemDeref should be legal on a LOCKED pointer.

Not only the built-in apps, but the ROM source code does it too.

The particular need is in some code I use to grow the handle that is
attached to a field. In order to detach the handle, grow it, and then
reattach to the field, I have to get the offset into the handle that the
field is using. The FieldType structure only has the handle, and the
pointer to the memory being used. When the built-in ROM needs to grow
memory, it does a MemDeref, and then subtracts the field pointer from the
derefed handle in order to compute the offset, which is what I was doing.

I am going to change the code to do a lock and unlock to get the pointer.
Since the built-in apps feel the need to deref a handle, and the ROM source
needs to do it, there should be a legitimate API call to do it.

Shannon

>At 4:23 PM -0700 7/19/99, Shannon wrote:
>>Some users are reporting crashes on a Palm VII. The crash happens right
>>when I use MemDeref on a locked handle.
>
>You should never use MemDeref on a locked handle!
>
>MemDeref is a weird old debugging function that unmunges the handle and
>follows the master pointer.  This gives you the address of the chunk, just
>like you'd get from MemHandleLock, but without locking it down.
>
>So it's a lot like keeping the pointer after you've called MemHandleUnlock
>- -- e.g. a bad idea.  If an allocation kicks off a compaction, or if you
>have the right debugging switches, the chunk will move (because it's not
>locked) and your pointer will be bad.
>
>Some of the built-in apps (which we ship as sample code) use MemDeref as an
>easy way to get the pointer from a handle without locking it an extra time.
>That's still ugly, but at least it's not a bug.  You should not do that --
>just use MemHandleLock to get the pointer legitimately.
>
>                               --Bob

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hands High Software
Award winning software for the Palm(tm) Computing platform

<http://www.handshigh.com/>

[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to