Jim Idle wrote: > On Sep 23, 2009, at 5:31 PM, David-Sarah Hopwood > <[email protected]> wrote: > >> "free(NULL)" is defined to be a no-op by the C standard. A libc >> implementation that got this wrong would be badly broken, and AFAIK all >> the commonly used platforms get it right. > > Some platforms define this to be undefined though. Remember there are > lots if embedded systems that use this. Hence the qualification. I think > it would have been better to define free(NULL) as safe myself but early > Lib C would crash if you did this and I think it was C++ that first took > a stand?
Perhaps very early libc's, but it is defined to be a no-op in C89. Note that in a system with memory protection, if it does crash then it will do so immediately with a segfault (at which point you should complain vigorously to the libc provider). I do realise that not all systems have memory protection -- but at the end of the day you can't hope to defend against bugs in a C implementation in application code, and this behaviour for free(NULL) is not an obscure thing to rely on. -- David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
