mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-26 02:20:51 +01:00
b2b29aad0d
Obtained from: http://www.cvshome.org/
26 lines
433 B
C
26 lines
433 B
C
/* valloc -- return memory aligned to the page size. */
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "system.h"
|
|
|
|
#ifndef HAVE_GETPAGESIZE
|
|
# include "getpagesize.h"
|
|
#endif
|
|
|
|
void *
|
|
valloc (bytes)
|
|
size_t bytes;
|
|
{
|
|
long pagesize;
|
|
char *ret;
|
|
|
|
pagesize = getpagesize ();
|
|
ret = (char *) malloc (bytes + pagesize - 1);
|
|
if (ret)
|
|
ret = (char *) ((long) (ret + pagesize - 1) &~ (pagesize - 1));
|
|
return ret;
|
|
}
|