📄 mystdlib.c
字号:
#include <stdio.h>#include <stdlib.h>#include <assert.h>#include "error.h"#include "mystdlib.h"long usedMemory = 0;void *checkedMalloc (int size){ if (size < 0) exception ("what going on here?\n"); //printf ("size=%d\n", size); void *temp = malloc (size); if (!temp) { //printf ("%d\n", size); printf ("used memory: %lfG\n", usedMemory*1.0/1024/1024/1024); exception ("no memory!\n"); } usedMemory += size; return temp;}void checkedFree (void *p){ if (p) { //printf ("checked freeing\n"); free (p); } else error ("try to free null pointers\n");}int checkedSystem (const char *s){ return system (s);}void *checkedRealloc (void *p, unsigned int size){ void *temp = realloc (p, size); assert (temp); return temp;}void memoryStatus (){ printf ("memory used = %lfG\n", usedMemory*1.0/1024/1024/1024);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -