you are right. Maybe I always bear in mind that a pointer variable must be
assigned address of another variable or memory allocated by the system.  My
mind is more clear now. Thanks a lot!


"Keith Rollin" <[EMAIL PROTECTED]> ??? news:[EMAIL PROTECTED]
???...

> From: DongDong [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 26, 2003 8:44 AM
> To: Palm Developer Forum
> Subject: Re: Question on a routine
>
> 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.

You can assign any value to a pointer variable.  Even 0x0000.  That is,
after all, what NULL is (on most systems anyway, and on the Palm in
particular).

The thing you have to worry about is *using* such a pointer variable to
retrieve any values from memory.  Thus, "&packed->status" is OK, because
it's just calculating an address, but "packed->status" is not OK, because
that's trying to fetch a value from memory during a time that "packed" is
not actually pointing to an allocated structure.

-- Keith




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

Reply via email to