Paul,

recPtr is a UInt8*, so Neil's math is correct. recPtr[sizeof(UInt32)] is
recPtr[4], which is 4 bytes from the beginning of the buffer.

However, I'm pretty sure that that second parameter should be be the *address*
of the element. That is, "&recPtr[sizeof(UInt32)]".

-- Keith






Paul Bohme <[EMAIL PROTECTED]> on 10/03/2000 10:43:41 AM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  Paul Bohme <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  RE: Compilation error with C++



> Do the following instead:
>     UInt8     *recPtr;
>     recPtr = (UInt8 *) MemHandleLock(recHandle);
>     ...
>   MemMove(pSig, recPtr[sizeof(UInt32)],
MemPtrSize(recPtr)-sizeof(UInt32));

  Yipes!  Almost.  The above will actually move it forward sizeof(UInt32) *
sizeof(UInt32) - probably more than you want.  To get the proper math, use a
CharPtr instead for your recPtr - so when you add a number to it or use an
array offset, it'll be doing single-byte moves instead of in increments of
sizeof(UInt32).
  Also, if it's C++, might want to consider the conventional static_cast<>
instead of the C-style cast - but that's just me being anal. ;-)

  -P

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





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