[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] valloc()?
From: |
Derek Price |
Subject: |
[bug-gnulib] valloc()? |
Date: |
Tue, 01 Mar 2005 19:01:32 -0500 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
Hey all,
I was just looking into merging or eliminating the last few files
compiled into libcvs.a that don't come from GNULIB. I have some
questions about valloc().
First, I found man pages stating that valloc() was obsoleted in favor of
posix_memalign(). Does anyone have a feel for how portable
posix_memalign() is, especially to obstinately non-POSIX platforms like
Windows?
Second, if posix_memalign() is not portable, is there any interest in a
GNULIB module either to replace it or valloc()? I've attached the
valloc.c that CVS is currently using.
Looking forward to your comments,
Derek
/* valloc -- return memory aligned to the page size. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef HAVE_GETPAGESIZE
# include "getpagesize.h"
#endif
void *
valloc (bytes)
size_t bytes;
{
long pagesize;
void *ret;
pagesize = getpagesize ();
ret = malloc (bytes + pagesize - 1);
if (ret)
ret = (long) (ret + pagesize - 1) &~ (pagesize - 1);
return ret;
}
signature.asc
Description: OpenPGP digital signature