sbrk_r.c
来自「FAT16 Filesystem on Philips LPC2000 seri」· C语言 代码 · 共 23 行
C
23 行
#include <reent.h>#include <sysdefs.h>extern char * end;static char * heap = 0;void * _sbrk_r (struct _reent *ptr, ptrdiff_t incr){char * ret; if (heap == 0) heap = (char *) &end; // check to see if RAM is exhausted. if ((unsigned)(heap + incr) >= END_OF_THE_RAM_FIELD) { ret = (void *)-1; } else { // nope, RAM is still available to malloc() // note address and effectively reserve it. ret = heap; heap += incr; } // return address of newly allocated RAM. return (void *) ret;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?