This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: malloc-based ggc-page
On Wed, Jan 19, 2000 at 11:01:42PM -0200, Alexandre Oliva wrote:
> On Jan 19, 2000, Marc Espie <espie@quatramaran.ens.fr> wrote:
>
> > Read carefully. valloc(size) is implemented by calling malloc after adding
> > pagesize-1 to size. So unless size == 0, malloc is called with something
> > larger than a page, so malloc's result is aligned on a page boundary.
>
> This information can't be derived from the snippet you posted. Is it
> really true that malloc on OpenBSD will return a page-aligned address
> just because size > pagesize? This would mean a lot of memory is
> wasted!
This information *can* be derived from the snippet I posted, unless you
don't trust vmalloc's man page.
malloc says the same thing.
Most modern mallocs use fixed size-buckets, arranged in power of 2 sizes
to speed things up. Not losing for allocations > page size just means
storing the malloc size elsewhere, like using a separate index of pages,
and storing only identical-size fragments in a given page.
I won't post such a long snippet here, but you can retrieve that malloc
from any OpenBSD cvs mirror,
src/lib/libc/stdlib/malloc.c