test3_1.c

来自「内存检测程序源代码」· C语言 代码 · 共 31 行

C
31
字号
/* test3_1.c
 * This example program shows how to temporarily disable MSS.  Maybe it isn't
 * the best example but you should get the idea - the program allocates 100,
 * 200 and 400 bytes, but in the log you should see only the allocations of 
 * 100 and 400.
 */
#include <mss.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	void * mem;
	puts("Logged allocation...");
	mem = malloc(100);
	free(mem);
#ifdef MSS
#include <no_mss.h>
#endif
	puts("Unlogged allocation...");
	mem = malloc(200);
	free(mem);
#ifdef __MSS_H_REINCLUDE
#include <mss.h>
#endif
	puts("Logged again...");
	mem = malloc(400);
	free(mem);
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?