Subject: Re: malloc_usable_size () call under NetBSD
To: None <tech-kern@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 07/20/2007 21:47:08
On Fri, Jul 20, 2007 at 09:15:07AM -0400, der Mouse wrote:
> >> complaining to lack the "malloc_usable_size ()" system call.
> > If we ever want to get this into pkgsrc, DO NOT USE THAT CALL.  It is
> > completely bogus exposure of malloc internals.
> 
> It is?  I don't see what's wrong with it.  Any malloc implementation
> could add it, if necessary by simply always returning the size passed
> to malloc for the block in question.

Well, most practical malloc implementation can. All? I don't know. I
could think of a malloc implementation that doesn't free memory and
doesn't keep track of memory either. Everytime you call realloc, it
copies up min((last_allocated - cur_pointer), new_len) to
last_allocated and increase it. What value should malloc_usable_size
return here?

Joerg