Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 1997 07:40:15 +0200
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        "Jordan K. Hubbard" <jkh@time.cdrom.com>
Cc:        Eivind Eklund <eivind@bitbox.follo.net>, Nate Williams <nate@mt.sri.com>, Eivind Eklund <perhaps@yes.no>, hackers@freebsd.org
Subject:   Re: Bug in malloc/free (was: Memory leak in getservbyXXX?) 
Message-ID:  <8858.874906815@critter.freebsd.dk>
In-Reply-To: Your message of "Sun, 21 Sep 1997 16:50:38 PDT." <24205.874885838@time.cdrom.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <24205.874885838@time.cdrom.com>, "Jordan K. Hubbard" writes:
>> It doesn't.  However, it has a formulation that IMHO is too
>> restrictive - that free() 'makes the memory available for further use
>> by the program' (from memory).  Thus, an implementation of
>
>Bizarre, are you sure?  That's exactly 180 degrees counter to what
>I've always learned about storage allocators: If you count on free()
>to not corrupt the data you pass to it, you deserve to lose and lose
>big.

Look, it's really very simple.  In other text it says that you cannot
know what's in the storage you get with malloc, so the only way to 
know if you got the same storage back would be to compare the pointer.

Second, I think the above wording is intended to avoid implementations
of this kind:

	static u_char *malloc_ptr = end;

	void *
	malloc(int n)
	{
		void *p;

		p = malloc_ptr;
		malloc_ptr += n;
		return p;
	}

	void
	free(void *)
	{
	}

--
Poul-Henning Kamp             FreeBSD coreteam member
phk@FreeBSD.ORG               "Real hackers run -current on their laptop."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8858.874906815>