morecore.c 892 B

12345678910111213141516171819202122232425262728
  1. /* morecore.c - C library support routine for UNIX.
  2. Copyright (c) 1989, 1993 Michael J. Haertel
  3. You may redistribute this library under the terms of the
  4. GNU Library General Public License (version 2 or any later
  5. version) as published by the Free Software Foundation.
  6. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
  7. WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR
  8. WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
  9. SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */
  10. #include <limits.h>
  11. #include <stddef.h>
  12. #include "malloc.h"
  13. extern void *sbrk(int);
  14. /* Note that morecore has to take a signed argument so
  15. that negative values can return memory to the system. */
  16. void *
  17. __default_morecore_init(long size)
  18. {
  19. void *result;
  20. result = sbrk(size);
  21. if (result == (void *) -1)
  22. return NULL;
  23. return result;
  24. }