2011-02-17 18:11:09 +01:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
#include <lib.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#ifdef __weak_alias
|
|
|
|
__weak_alias(sbrk, _sbrk)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern char *_brksize;
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
void *sbrk(incr)
|
2011-02-17 18:11:09 +01:00
|
|
|
intptr_t incr;
|
|
|
|
{
|
|
|
|
char *newsize, *oldsize;
|
|
|
|
|
|
|
|
oldsize = _brksize;
|
|
|
|
newsize = _brksize + incr;
|
|
|
|
if ((incr > 0 && newsize < oldsize) || (incr < 0 && newsize > oldsize))
|
|
|
|
return( (char *) -1);
|
|
|
|
if (brk(newsize) == 0)
|
|
|
|
return(oldsize);
|
|
|
|
else
|
|
|
|
return( (char *) -1);
|
|
|
|
}
|