1 /* $NetBSD: morecore.c,v 1.2 2016/01/13 21:56:38 christos Exp $ */ 2 3 /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. 4 This file is part of the GNU C Library. 5 6 The GNU C Library is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 The GNU C Library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with the GNU C Library; see the file COPYING. If not, write to 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 19 20 #ifndef _MALLOC_INTERNAL 21 #define _MALLOC_INTERNAL 22 #include <malloc.h> 23 #include <unistd.h> 24 #endif 25 26 #ifndef __GNU_LIBRARY__ 27 #define __sbrk sbrk 28 #endif 29 30 #ifdef __GNU_LIBRARY__ 31 /* It is best not to declare this and cast its result on foreign operating 32 systems with potentially hostile include files. */ 33 extern __ptr_t __sbrk __P ((int increment)); 34 #endif 35 36 #ifndef NULL 37 #define NULL 0 38 #endif 39 40 /* Allocate INCREMENT more bytes of data space, 41 and return the start of data space, or NULL on errors. 42 If INCREMENT is negative, shrink data space. */ 43 __ptr_t 44 __default_morecore (increment) 45 #ifdef __STDC__ 46 ptrdiff_t increment; 47 #else 48 int increment; 49 #endif 50 { 51 __ptr_t result = (__ptr_t) __sbrk ((int) increment); 52 if (result == (__ptr_t) -1) 53 return NULL; 54 return result; 55 } 56