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