morecore.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. The GNU C 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
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with the GNU C Library; see the file COPYING. If not, write to
  13. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  14. #ifndef _MALLOC_INTERNAL
  15. #define _MALLOC_INTERNAL
  16. #include <malloc.h>
  17. #endif
  18. #ifndef __GNU_LIBRARY__
  19. #define __sbrk sbrk
  20. #endif
  21. #ifdef __GNU_LIBRARY__
  22. /* It is best not to declare this and cast its result on foreign operating
  23. systems with potentially hostile include files. */
  24. extern __ptr_t __sbrk __P ((int increment));
  25. #endif
  26. #ifndef NULL
  27. #define NULL 0
  28. #endif
  29. /* Allocate INCREMENT more bytes of data space,
  30. and return the start of data space, or NULL on errors.
  31. If INCREMENT is negative, shrink data space. */
  32. __ptr_t
  33. __default_morecore (increment)
  34. #ifdef __STDC__
  35. ptrdiff_t increment;
  36. #else
  37. int increment;
  38. #endif
  39. {
  40. __ptr_t result = (__ptr_t) __sbrk ((int) increment);
  41. if (result == (__ptr_t) -1)
  42. return NULL;
  43. return result;
  44. }