> From: owner-openssl-us...@openssl.org On Behalf Of Ger Hobbelt > Sent: Thursday, 09 April, 2009 08:43 <snip other points about configuring for debug>
> And by the way, which made me scratch my head: malloc(0) is > an illegal invocation of malloc anyhow and you should check > for that (a LOT of systems will coredump on you when you do > that sort of thing); see the ANSI spec, but also, for example: > http://bytes.com/groups/c/508471-malloc-0-a and the answer > there by Lew Pitcher. > No, see the answer by Keith Thompson (no relation <G>), who is a regular on comp.lang.c where this is a fairly-FAQ and so is the related question of free(null). Although Pitcher was also pretty good; I'm surprised he got this one wrong. Implementation-defined with a list means it can do either choice (return null or return a pointer you can't legally dereference), and a portable program can't depend on which, but nothing else. Some pre-standard systems may have coredumped, but that should have been fixed 20 years ago. Some pre-standard systems certainly DID coredump for free(null), before C89 guaranteed a no-op. malloc(0) is generally USELESS, and code using it may well be confusing and misleading, but it is not illegal or unsafe. realloc(null,0) OTOH was reworded between C90 and C99, and is now somewhat controversial -- as well as similarly useless. PS- it's rather costly to get C89=ANSI or C90=ISO, but C99 (technically the INCITS adoption of it) can be bought from ANSI's webstore for USD30, and drafts are available free on the committee website http://www.open-std.org/jtc1/sc22/wg14/ . (The 'document register' link doesn't show it, but individual documents are all in www/docs except some restricted ones.) www/docs/n869/ were the last draft before adoption of C99. There have been several post-C99 drafts as they are now working toward C1x; as I recall, n1256 is C99 + technical corrigenda, but not yet any substantive changes. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org