text1.txt
来自「《突破Visual C++.NET编程实例五十讲+源文件,初学者学习的好东东!」· 文本 代码 · 共 32 行
TXT
32 行
BoundsChecker found a memory leak in InitDialog because the CImageList pointer is allocated on the heap with
"new" but never deleted.
To solve this leak, I made pImageList a private variable instead of a pointer.
CImageList m_ImageList; //add this to the header file
You have to change the references to pImageList from pointers (pImageList->Create, etc.) to
non-pointers (m_ImageList.Create, etc.).
When this is done the memory leak goes away.
When you change drives, and if the current directory on the new drive happens to be root you get an
error(compiled under VC++ 4.2)because in the Add dirs to tree routine
void CDirectoryTree::AddDirsToTree(CString szStart, HTREEITEM htParent)
{
szStartDir.Format("%s\\*.*", szStart);
szStart is something like "c:\" so it already has the slash unlike
"d:\mydir" that does not have the slash. So you have to distinguish based on the current
directory name. A simpe way is as following
int len = strlen(szStart) - 1;
if(szStart[len] != '\\')
szStartDir.Format("%s\\*.*", szStart);
else
szStartDir.Format("%s*.*", szStart);
aLSO vc++ 4.2 complains about memory leak that I did not have time to look into.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?