some coverity fixes.
[minix.git] / lib / libc / sys-minix / sbrk.c
bloba940c4bcc7561d1f44aeb69bbcb629f28e143536
1 #include <sys/cdefs.h>
2 #include "namespace.h"
3 #include <lib.h>
5 #include <unistd.h>
7 #ifdef __weak_alias
8 __weak_alias(sbrk, _sbrk)
9 #endif
11 extern char *_brksize;
13 void *sbrk(incr)
14 intptr_t incr;
16 char *newsize, *oldsize;
18 oldsize = _brksize;
19 newsize = _brksize + incr;
20 if ((incr > 0 && newsize < oldsize) || (incr < 0 && newsize > oldsize))
21 return( (char *) -1);
22 if (brk(newsize) == 0)
23 return(oldsize);
24 else
25 return( (char *) -1);