Ok,
So two address two things, one if my something_t was defined thusly:
typdef struct {
char * cp;
void * vp;
char data[100];
} something_t;
and:
something_t *sp;
then this would be pedantic and correct:
if (sp=zmalloc(sizeof(something_t))) {
sp->cp = NULL;
sp->vp = NULL;
...
}
or:
if (sp=zmalloc(sizeof(something_t))) {
sp->cp = (char *)0;
sp->vp = (void *)0;
...
}
Secondly, I think this is academic, as on the subject of null pointers K&R
say: "The symbolic constant NULL is often used in place of zero, as a
mnemonic to indicate more clearly that this is a special value for a
pointer. NULL is defined in <stdio.h>" [1]
So the only time our bzero(), memset() to zero, setting to interger zero,
etc. would unravel is if you have a (strange?) compiler/environment that has
a definition for NULL of other than zero in <stdio.h>
Assuming that this is not the case and NULL is defined as zero on all
systems then it is only a matter of coding style(s) and compiler warnings if
you do things like leave out cast operators.
Mike
[1] "The C Programming Language", Brian W. Kernighan & Dennis M. Ritchie,
2nd Edn., 1988, Prentice Hall Software Series, pp. 102
-----Original Message-----
From: John Hall [
mailto:j@jdh28.co.uk]
Sent: 10 October 2006 09:39
To: exim-users@???
Cc: Peter D. Gray; Chris Lightfoot
Subject: Re: [exim] Off-topic coding style (was: [BUG?]
insrc/auths/pwcheck.c)
On 10/10/06, Michael J. Tubby G8TIC <mike.tubby@???> wrote:
> with a local implementation (in library code) of zmalloc that looks like:
>
> void * zmalloc(size_t size)
> {
> void * p = malloc(size);
> if (p)
> memset(p, 0, size);
> return p;
> }
I'm in the habit of just using calloc(1, size), which zeroes memory.
regards,
John
--
## List details at
http://www.exim.org/mailman/listinfo/exim-users
## Exim details at
http://www.exim.org/
## Please use the Wiki with this list -
http://www.exim.org/eximwiki/