summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/lib/valloc.c
blob: 17fb14b64d78e5c61f252ef9fe6795ae2456afea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* 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;
}
OpenPOWER on IntegriCloud