www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/10/19:09:28

Date: Wed, 10 Jan 1996 19:01:02 -0500 (EST)
From: Cuthalion / Sliced Bread <enrico AT max DOT tiac DOT net>
To: kagel AT quasar DOT bloomberg DOT com
cc: dunder AT nyongwa DOT montreal DOT qc DOT ca, djgpp AT delorie DOT com
Subject: Re: (none)
Message-ID: <Pine.NEB.3.91.960110185818.15919A-100000@max.tiac.net>
MIME-Version: 1.0

On Wed, 10 Jan 1996 kagel AT quasar DOT bloomberg DOT com wrote:

> 	if (!my_pointer)
> 		my_pointer = (my_struct_t *)malloc( sizeof (my_struct_t) ); 
> 
> Or BETTER CODE but equivalent:
> 
> 	if (my_pointer == (my_struct_t *)NULL)
> 		...

	You shouldn't need to cast NULL, I don't think...  

	Either way, even better than that would be:
	if (NULL == my_pointer) ...
	since this will give you a compiler error if you make a typo and 
only use one equal sign.  (Otherwise, it is an assignment, which can 
cause no end of problems.  It's also a PAIN to find, when you do do it.)

/***********************************************************************
* Jesse Morris * cuth AT gryphon DOT ccs DOT brandeis DOT edu * jrmorris AT macalstr DOT edu *
****************   Cuthalion / Sliced Bread    *************************
              \*********************************/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019