valloc()?

Derek Price <[email protected]> Tue, 01 Mar 2005 19:01:32 -0500
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs
Organization Get CVS Support from Ximbiot <http://ximbiot.com>!
Message-ID <[email protected]>
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

_______________________________________________
bug-gnulib mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnulib
valloc.c (text/plain, 392 B)
/* 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 (application/pgp-signature, 253 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCJQJcLD1OTBfyMaQRAqIwAJ41aDhQ8uCG9YPt2r9L3SXWsMZrSACeN6QS
+F03OStVFEaup7kAzgXlUhQ=
=nsiz
-----END PGP SIGNATURE-----