?? 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 + -