bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: posix_memalign, valloc


From: Bruno Haible
Subject: Re: posix_memalign, valloc
Date: Sat, 26 Nov 2011 00:25:06 +0100
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

[Dropping libvir-list]

Peter O'Gorman wrote:
> Many of these systems have valloc(3) which could be used for this purpose.

Yes, but gnulib's pagealign_alloc() function is less wasteful that the
valloc() function that some systems have. E.g. in OpenBSD:

void *
valloc(size_t i)
{
        long valsiz = getpagesize(), j;
        void *cp = malloc(i + (valsiz-1));

        j = ((long)cp + (valsiz-1)) &~ (valsiz-1);
        return ((void *)j);
}

This implementation nearly always wastes an entire page of memory.

Bruno
-- 
In memoriam Valentín Elizalde <http://en.wikipedia.org/wiki/Valentín_Elizalde>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]