Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: why is free() a void? Message-ID: <14373@smoke.brl.mil> Date: 7 Nov 90 10:28:08 GMT References: <1990Oct25.152057.23024@zoo.toronto.edu> <14@christmas.UUCP> <1990Oct30.172429.10055@Think.COM> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 19 In article <1990Oct30.172429.10055@Think.COM> barmar@think.com (Barry Margolin) writes: >The problem with the ANSI specification is that free is *prohibited* from >returning an error indication that a portable program can use. It would >have been better if it had been defined to return an int, with the >specification that the implementation is not required to validate the >argument, but if it does so then it may return -1 and set errno if it fails >the validation. (a) The C standard is based on existing practice, and existing free() does not return a validation value. (b) It would be impossible to completely verify that the pointer passed to free() is appropriate. (c) It would be expensive to partially verify that the pointer passed to free() is appropriate. (d) It would be silly to write code that relied on this run-time validation if it's not guaranteed to be done anyway.