Subject: Re: calloc() and free() ps doesn'r report memory being freed, why?
To: None <JohnAM@datastorm.com, netbsd-help@NetBSD.ORG, netbsd-users@NetBSD.ORG>
From: Peter Seebach <seebs@solon.com>
List: netbsd-help
Date: 07/29/1996 11:47:58
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.

The only way to enforce this is to mark the memory as free, but keep it in the
process's address space.

This is discussed in the comp.lang.c FAQ.

The free(*ptr) is wrong, BTW.  In case you didn't know.

My advice would be to allocate a lot less memory for this.  Or, look into
using alloca() or a recursive function so you're using stack space.

-s