valloc.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* Allocate memory on a page boundary.
  2. Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of the
  6. License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with this library; see the file COPYING.LIB. If
  13. not, see <http://www.gnu.org/licenses/>.
  14. The author may be reached (Email) at the address mike@@ai.mit.edu,
  15. or (US mail) as Mike Haertel c/o Free Software Foundation. */
  16. #include <stdlib.h>
  17. #include <unistd.h>
  18. #include <malloc.h>
  19. static size_t pagesize;
  20. __ptr_t valloc (size_t size)
  21. {
  22. if (pagesize == 0)
  23. pagesize = getpagesize ();
  24. return memalign(pagesize, size);
  25. }