Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/src/cmd/cvs/cvs-1.11.23/lib/valloc.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/* 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;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].