aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/sys/sysvi386/sbrk.c
blob: 8ae3ed12b5df3fdc6dab96517acd01aff535ca06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
extern end;

static void *curbrk = (char*)&end;

void *
sbrk(incr)
int incr; {
	extern int errno;
	extern int _brk(void *);
	void *ptr = curbrk;
	int t;

	if (incr == 0)
		return curbrk;
	t = _brk (curbrk + incr);
	if (t == -1 && errno)
		return (void *)-1;
	curbrk = ((char *)curbrk) + incr;
	return ptr;
}