メモリリークがすべてだったようです。関数の_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();
何か間違っていることがわかりますか?