⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mystdlib.c

📁 压缩包里面的都是精致的基本C语言小程序
💻 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 + -