Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - NULL Pointers
  
User name:
Password:
Reply:
 

UserPost
HyperLamer
Posts: 6167/8210
No OS I know of would assign memory that low. That area's generally reserved for the OS or BIOS. OSes usually reserve the lowest memory addresses for themselves.
Ramsus
Posts: 153/162
When used as a pointer value in C, the constant 0 is always considered NULL according to the language's standard, not the actual memory address 0. In fact, the system can use any value it wants to represent a NULL pointer and the constant 0 will always be equivalent to it in any pointer context (e.g. assignment to a pointer variable).

If you're doing system-specific C code and store pointer addresses in something not a pointer, like an integer, you'll need to typecast 0 as (void *) in order to store an actual NULL value.
beneficii
Posts: 376/567
Originally posted by Disch
On most systems -- no, you will never get a return of 0 (except on error).

However, that's why you're supposed to use NULL and not 0 (since were a system to have 0 a valid address, you would only have to redefine NULL to make it something else). I never stuck to that though, and I treat NULL as 0 always.


Even if 0 were a valid address... the lowest you could get would probably be like 8 or 16 or something -- since memory allocation functions allocate a bit more than you request and prefix it with information (like allocated size, and boundary checks)


Whoo, that just took a load off my back! Thanks Disch!

My guess is that 0 is used by the system somehow (like for BIOS or something).
Dish
Posts: 489/596
On most systems -- no, you will never get a return of 0 (except on error).

However, that's why you're supposed to use NULL and not 0 (since were a system to have 0 a valid address, you would only have to redefine NULL to make it something else). I never stuck to that though, and I treat NULL as 0 always.


Even if 0 were a valid address... the lowest you could get would probably be like 8 or 16 or something -- since memory allocation functions allocate a bit more than you request and prefix it with information (like allocated size, and boundary checks)
beneficii
Posts: 375/567
I wonder, If you malloc a pointer or create any variable, will it ever get assigned the address of 0 (NULL)? In other words, will a pointer ever get a NULL address from the system?
Acmlm's Board - I2 Archive - Programming - NULL Pointers


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.010 seconds.