EXPORT void *realloc(void *mem, Uint bytes);\r
EXPORT void *sbrk(int increment);\r
LOCAL void *extendHeap(int bytes);\r
-LOCAL uint brk(int delta);\r
+LOCAL uint brk(Uint newpos);\r
\r
//Code\r
\r
static size_t oldEnd = 0;\r
static size_t curEnd = 0;\r
\r
- //SysDebug("sbrk: (increment=%i)\n", increment);\r
+ //_SysDebug("sbrk: (increment=%i)\n", increment);\r
\r
if (oldEnd == 0) curEnd = oldEnd = brk(0);\r
\r
return NULL;\r
}\r
\r
-LOCAL uint brk(int delta)\r
+LOCAL uint brk(Uint newpos)\r
{\r
static uint curpos;\r
uint pages;\r
uint ret = curpos;\r
+ int delta;\r
+ \r
+ //_SysDebug("brk: (newpos=0x%x)", newpos);\r
\r
// Find initial position\r
if(curpos == 0) curpos = (uint)FindHeapBase();\r
\r
// Get Current Position\r
- if(delta == 0)\r
- {\r
- return curpos;\r
- }\r
+ if(newpos == 0) return curpos;\r
+ \r
+ if(newpos < curpos) return newpos;\r
+ \r
+ delta = newpos - curpos;\r
+ //_SysDebug(" brk: delta = 0x%x", delta);\r
\r
// Do we need to add pages\r
if(curpos & 0xFFF && (curpos & 0xFFF) + delta < 0x1000)\r