Subject: Re: calloc() and free() ps doesn'r report memory being freed, why?
To: None <netbsd-help@NetBSD.ORG>
From: Ty Sarna <tsarna@endicor.com>
List: netbsd-help
Date: 07/30/1996 03:03:55
In article <199607291647.LAA12585@solutions.solon.com>,
Peter Seebach  <seebs@solon.com> wrote:
> This is not merely correct, but required by ISO C.
> 
> 7.10.3.2:
> 	"The free function causes the space pointed to by ptr to be
> 	 deallocated, that is, made available for further allocation."
> 
> Since the standard does not document the existance of other programs, if you
> have allocated space, and then freed it, you *must* be able to allocate it
> again.

Actually, I think it has more to do with implementation difficulty than
obsessive-compulsive standards conformance.  After all, under NetBSD,
you aren't even guaranteed to get memory you supposedly have already
allocated, due to the lazy swap allocation policy.  Furthermore, I'd say
most non-Unixoid systems (and perhaps many Unix systems as well) fail to
follow the standard in that respect.  I would consider it very poor
programming practice to assume that because you just free()d N bytes that
you will be able to sucessfully malloc() than many again.  *Always* check
allocations!