"DHOLLINGSWORTH2" < XXXX@XXXXX.COM > writes:
First of all, "if (!ptr)" and "if (ptr != 0)" are exactly equivalent;
they both test whether the pointer is non-null.
It's guaranteed that malloc() returns either a null pointer or a valid
pointer (unless memory has been corrupted by something that invoked
undefined behavior, in which case all bets are off anyway).
You might as well assume that any non-null pointer is valid, because
there's no way in standard C to determine that a non-null pointer is
invalid. You just have to make sure that you don't use any invalid
pointers in the first place.
Section 5 of the C FAQ < http://www.yqcomputer.com/
discusses null pointers; it's highly recommended.
Keith Thompson (The_Other_Keith) XXXX@XXXXX.COM < http://www.yqcomputer.com/
San Diego Supercomputer Center <*> < http://www.yqcomputer.com/
We must do something. This is something. Therefore, we must do this.