why is free() a void?

Henry Spencer henry at zoo.toronto.edu
Fri Oct 26 01:20:57 AEST 1990


In article <1749 at meaddata.meaddata.com> rob at pmserv.meaddata.com writes:
>    "void free(void *p)
>        ... p MUST be a pointer to space previously allocated by calloc,
>        malloc, or realloc."   (Emphasis on MUST by me.)
>
>What happens if p WASN'T allocated as it should've been??  How do we know
>there was a problem??  ...

"Bus error - core dumped."  Handing free() an improper pointer is a major
error, and one that free() is *not* required to catch.  It can screw up in
any manner it pleases if you do this.  There is little point in allowing
for a return code just to complain about something you are *never* *ever*
supposed to do in the first place.
-- 
The type syntax for C is essentially   | Henry Spencer at U of Toronto Zoology
unparsable.             --Rob Pike     |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list