00001 00008 #include "sceptre.h" 00009 #include <reent.h> 00010 00011 00016 extern char end[]; 00017 00018 static char * heap = 0; 00019 00020 00029 void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) 00030 { 00031 char * ret; 00032 //if (heap==0) heap = (char *) end; 00033 if (heap==0) heap = end; 00034 00035 // Check to see if RAM is exhausted. 00036 if ((unsigned)(heap + incr) >= TARGET_END_OF_RAM) 00037 { 00038 ret = (void *)-1; 00039 } 00040 else 00041 { 00042 // Nope, RAM is still available to malloc(), 00043 // note address and effectively reserve it. 00044 ret = heap; 00045 heap += incr; 00046 } 00047 00048 // Return address of newly allocated RAM. 00049 return (void *) ret; 00050 } 00051