Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Sep 1997 22:35:52 -0400 (EDT)
From:      Tim Vanderhoek <tim@ppp6431.on.sympatico.ca>
To:        Sean Eric Fagan <sef@Kithrup.COM>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Bug in malloc/free (was: Memory leak in getservbyXXX?)
Message-ID:  <Pine.BSF.3.96.970921223229.215A-100000@ppp6431.on.sympatico.ca>
In-Reply-To: <199709220129.SAA24046@kithrup.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 21 Sep 1997, Sean Eric Fagan wrote:

> Lastly, the wording for free() is, as I understood it when I last read it,
> meant to convey the requirement that:
> 
> 	char *cp = malloc(100);
> 	if (cp) {
> 		free(cp);
> 		cp = malloc(100);
> 	}
> 
> always result in a non-NULL cp.
> 
> So, in conclusion:  yes, the OS is perfectly free to have free() return the
> memory back to the OS, even though traditional systems did not do this most

No, if you want the above code to always result in a non-NULL cp,
free() cannot ever return the memory back to the OS.

However, I believe the actual wording is sufficiently ambigous that
this debate has been fought long and hard in other forums.  Anything
which is this controversial can be implemented either way and be
right. 

Besides, there ain't no standard which can tell me that free() can't
return memory to the OS.


--
 tIM...HOEk
OPTIMIZATION: the process of using many one-letter variables names
              hoping that the resultant code will run faster.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.970921223229.215A-100000>