📄 sbrk_r.c
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -