blob: 03ab3c14bba0824f927d0651dd4e32ff054eb5b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* sbrk.c - Change data segment size */
/* Written 2000 by Werner Almesberger */
#include <stddef.h>
#include <unistd.h>
#include <sys/types.h>
char *__current_brk; /* Common with brk.c */
void *sbrk(ptrdiff_t increment)
{
char *old_brk, *new_brk;
if (!__current_brk)
__current_brk = __brk(NULL);
new_brk = __brk(__current_brk+increment);
if (new_brk != __current_brk+increment)
return (void *) -1;
old_brk = __current_brk;
__current_brk = new_brk;
return old_brk;
}
|