TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Kurt Kuzba
from: Robin Sheppard
date: 1998-08-14 12:03:02
subject: NULL pointers

KK> Just do exactly that! :)
 KK> CONFIG *c;
 KK> int num_of_configs = atoi(argv[1]);
 KK> c = malloc(num_of_configs * sizeof(CONFIG));
 KK> if(!c)
 KK> {
 KK> puts("Malloc error in main() for CONFIG array.");
 KK> return 1;
 KK> }

   Is testing for a 'false pointer', ie, using the logical NOT operator 
   like you did above ANSI standard?  I know that different compilers 
   represent NULL differently, and it's not necessarily (in fact, probably 
   isn't) a pointer with the value zero.  As I understand it, a NULL 
   pointer just points to a predefined invalid address, which is quite 
   likely something outside of the bounds of allowable RAM.
   
   I'm just wondwering whether using this shortcut will compromise code 
   portability- if not, I'll save typing "!=NULL" from now on.  :>
   
... Any given program, when running, is obsolete.
___ Blue Wave/DOS v2.30 [NR]

--- Maximus 2.01wb
* Origin: Basic'ly Computers: Mooo-ing Right Along. (1:153/9)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728 810
SEEN-BY: 639/252 670/213 218
@PATH: 153/104 2 716 7715 140/1 270/101 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.