<[EMAIL PROTECTED]> ??? news:[EMAIL PROTECTED] ???...
>
> Yes, I remember staring at that code myself.  It's kind of grungy.
>
> In:
>
> LibPackedDBRecord *packed=0;
>
> "packed" is simply a pointer (32-bits for Palm platform) so this just
> initializes it to zero.  Typically, you would say it as:
>
> LibPackedDBRecord *packed=NULL;
>
> but the author (I think) is intentionally using zero instead of NULL.
Think
> of *packed as pointing to a LibPackedDBRecord whose base address is zero.
>


Why could author assume the base address equal to zero? As most C programmer
know, memory should be allocated by system. The pointer shouldn't be
assigned an absolute address, even address 0x0000.

Is the address zero under Palm OS free to use? I'm confused.
Welcome to advice.



> Then the expression:
>
> &packed->status
>
> is the offset of the "status" member from the base address of a
> LibPackedDBRecord.  Note that &packed->status does not reference the value
> of "status" but only yields the offset of "status".  DmWrite requires the
> offset.
>
> To me it's kind of kludgy.  I probably would code it differently, or at
> least comment it better.
>



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

Reply via email to