Skip to content

修复甲级 1159 题内存泄漏的 bug,并添加甲级 1156 到 1159 题的索引#110

Open
SuYindu wants to merge 2 commits intoliuchuo:masterfrom
SuYindu:master
Open

修复甲级 1159 题内存泄漏的 bug,并添加甲级 1156 到 1159 题的索引#110
SuYindu wants to merge 2 commits intoliuchuo:masterfrom
SuYindu:master

Conversation

@SuYindu
Copy link
Contributor

@SuYindu SuYindu commented May 4, 2019

No description provided.

}
cout << (flag ? "Yes" : "No") << endl;
}
free(postorder);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resources of tree nodes still not deallocated. Consider std::shared_ptr<TreeNode> instead of raw pointers. Or a tree class with a destructor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote an example: Tree.h
Tree_test.cpp.
The allocated memory pointed to by smart pointers won't be deallocated until they reach their lifespan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants