似乎都是关于内存泄漏的,我在函数_CrtDumpMemoryLeaks();
之前和之后都使用过这个malloc
函数。在 malloc 之前我什么也得不到,当_CrtDumpMemoryLeaks();
在 malloc 之后运行时,我得到以下信息:
Detected memory leaks!
Dumping objects ->
c:\users\omers66\documents\visual studio 2013\projects\assigment4\assigment4 \assignment4.c(150) : {66} normal block at 0x00F57338, 20 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The program '[7588] assigment4.exe' has exited with code 0 (0x0).
我想这意味着我对第 150 行有疑问?但我看不出有什么问题,这是该部分中的代码:
struct Unit* add_unit(struct Unit* tree, int base, int newId, char*name)
{
_CrtDumpMemoryLeaks();
struct UnitList* tempUnitList;
struct Unit* temp;
struct Unit* returnValue = NULL;
char* helpName;
if (tree == NULL)
{
temp = ((struct Unit*)(malloc(sizeof(struct Unit)))); (line 150)
_CrtDumpMemoryLeaks();
你能看出什么不对吗?