PageRenderTime 155ms CodeModel.GetById 149ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/contrib/cvs/lib/valloc.c

https://bitbucket.org/freebsd/freebsd-head/
C | 25 lines | 19 code | 5 blank | 1 comment | 1 complexity | 0bbea233a4a712c9c1810aabda4e9592 MD5 | raw file
 1/* valloc -- return memory aligned to the page size.  */
 2
 3#ifdef HAVE_CONFIG_H
 4#include "config.h"
 5#endif
 6
 7#include "system.h"
 8
 9#ifndef HAVE_GETPAGESIZE
10# include "getpagesize.h"
11#endif
12
13void *
14valloc (bytes)
15     size_t bytes;
16{
17  long pagesize;
18  char *ret;
19
20  pagesize = getpagesize ();
21  ret = (char *) malloc (bytes + pagesize - 1);
22  if (ret)
23    ret = (char *) ((long) (ret + pagesize - 1) &~ (pagesize - 1));
24  return ret;
25}