Subject: Re: NULL return value checking
To: Matthew Mondor <mmondor@gobot.ca>
From: Alfred Perlstein <bright@mu.org>
List: tech-kern
Date: 04/23/2002 13:20:05
* Matthew Mondor <mmondor@gobot.ca> [020423 13:14] wrote:
> Is there real relevance to checking NULL return values against NULL itself, rather than simply using a boolean operation check?
>
> eg:
>
> if( (ptr = malloc(size)) !=NULL) {
>
> instead of
>
> if( (ptr = malloc(size)) ) {
>
> Because isn't NULL defined in <sys/types.h>, to 0L ?
It's a stylistic choice. Pointers are not boolean therefor you test
them against a value in order to derive a boolean for your test.
--
-Alfred Perlstein [alfred@freebsd.org]
'Instead of asking why a piece of software is using "1970s technology,"
start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/