calloc()

dtsteen at dahlia.waterloo.edu dtsteen at dahlia.waterloo.edu
Thu Jun 22 09:41:09 AEST 1989


I've just had a problem with an Amiga port of a Unix program (Bison)
which I tracked down to the program doing effectively the following:

      block = calloc(0,1);

As it turns out, this works fine on Unix (returning a nonzero pointer)
but not with the calloc() library function of Lattice 5.02 on the Amiga,
which returns a null.  This makes sense, but it has made me wonder,
which is the correct behaviour?  Should an allocate of no memory return
a null pointer or a valid pointer to no memory?

The Amiga compiler claims to be ANSI compliant, and the calloc() function
is one of the ANSI specified set.  What does the ANSI spec (which I don't
have) have to say about this?  Are special cases like this even
documented?
 
Any info would be appreciated.
 
Markus Wandel
(519) 884-9669



More information about the Comp.lang.c mailing list