debugmalloc_base.c

来自「SSD6网上教程全部练习及答案 原版的正确答案」· C语言 代码 · 共 42 行

C
42
字号
#include <stdlib.h>
#include <string.h>
#include "debugmalloc.h"
#include "dmhelper.h"
#include <stdio.h>


/* Wrappers for malloc and free */

void *MyMalloc(size_t size, char *filename, int linenumber) {
	return (malloc(size));
}

void MyFree(void *ptr, char *filename, int linenumber) {
	free(ptr);	
}

/* returns number of bytes allocated using MyMalloc/MyFree:
	used as a debugging tool to test for memory leaks */
int AllocatedSize() {
	return 0;
}



/* Optional functions */

/* Prints a list of all allocated blocks with the
	filename/line number when they were MALLOC'd */
void PrintAllocatedBlocks() {
	return;
}

/* Goes through the currently allocated blocks and checks
	to see if they are all valid.
	Returns -1 if it receives an error, 0 if all blocks are
	okay.
*/
int HeapCheck() {
	return 0;
}

⌨️ 快捷键说明

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