On Saturday 01 July 2006 04:35, Matthias Andree wrote: > Pat Lashley <[EMAIL PROTECTED]> writes: > > > BUT, that said, the safest and most portable coding practice would be: > > > > // The C standard does not require malloc(0) to return NULL; > > // but whatever it returns MUST NOT be dereferenced. > > ptr = ( size == 0 ) ? NULL : malloc( size ) ; > > Safest (avoiding null derefence) would instead be: > > ptr = malloc(size ? size : 1); > > BTW: // is not a valid C89 comment, but a GCC-ism.
It's valid in C99 though. :) -- John Baldwin _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"