Re: NULL and zeros



Yevgen Muntyan wrote:

Hey,

Are there not highly specialized and still existing and used platforms
where NULL is not a sequence of zeros, so that "char *a = NULL;" and
"char *a; memset (&a, 0, sizeof (a));" are not equivalent?

In other words, do I care about possible difference between NULL and
zero-filled pointer if e.g. I assume the target platform can run X
or it is Windows?

Have you read Question 5.17 in the comp.lang.c Frequently
Asked Questions (FAQ) list at <http://c-faq.com/>?

Also, have you read the tenth of the Ten Commandments for
C Programmers at <http://www.plethora.net/~seebs/c/10com.html>?

It takes a tiny bit more effort to zero your pointers portably
than to just use calloc() or memset() and hope for the best -- but
the additional effort *is* tiny, after all! It is unlikely that you
will run across a machine where all-bits-zero is not a null pointer;
it is also unlikely that your house will burn down, yet most people
I know pay for fire insurance. Keep in mind that fashions come and
go in our industry; it would be risky to assume that progress has
ceased and that machines of the future will be just like those of
today.

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: NULL and zeros
    ... Yevgen Muntyan wrote: ... Are there not highly specialized and still existing and used platforms ... do I care about possible difference between NULL and ... zero-filled pointer if e.g. ...
    (comp.lang.c)
  • NULL and zeros
    ... Are there not highly specialized and still existing and used platforms ... do I care about possible difference between NULL and ... zero-filled pointer if e.g. ... or it is Windows? ...
    (comp.lang.c)
  • Re: Thou shalt have no other gods before the ANSI C standard
    ... Because of these two platforms ... > The C standard does allow memcpy of pointer objects. ... New compiler development for such platforms is not a poor economic ...
    (sci.crypt)
  • Re: Why does rewind() ignore errors?
    ... promise that memsetting any scalar to zero on their implementations ... YOU can assume that all-zero-bits is a valid null pointer ... platforms where it is true. ... The C standard allows C implementations to run programs on those rare ...
    (comp.std.c)
  • Re: OpenSSL Hacks
    ... possible on many platforms when a null pointer is used as though it ... to denial-of-service are a crucial security goal. ... If you found a honest-to-goodness exploitable security vulnerability, ...
    (sci.crypt)