Re: coding standards

Robert Frank (frank@ifi.unibas.ch)
Mon, 11 May 1998 11:23:34 +0200

Date:	Mon, 11 May 1998 11:23:34 +0200
From:	Robert Frank <frank@ifi.unibas.ch>
Subject: Re: coding standards
To:	samba-technical@samba.anu.edu.au

<nofill> [...]

> > void *ptr = 0 is bad: this should be void *ptr = NULL
>
> As Andrew pointed out to me, the C standard does define NULL as a pointer
> with a value of zero. void *ptr = 0 isn't wrong, per se., it's just that
> it's much clearer to use NULL.
>
> A quick grep through /usr/include on my Linux box shows that NULL is
> typically defined as
>
> #define NULL ((void*)0)
>
> So the typecasting is done for you.
</nofill>

It's not just that. On some (older) system, e.g. PDP11, this was NOT 0! So
checking against 0 would fail on these systems.

<nofill>
-Robert
-------------------------------------
Institut fuer Informatik tel +41 (0)61 321 99 67
Universitaet Basel fax. +41 (0)61 321 99 15
Robert Frank
Mittlere Strasse 142 rfc822: frank@ifi.unibas.ch (NeXT,MIME mail ok)
CH-4056 Basel (remove any no_spam_ from my return address)
Switzerland
</nofill>