高手!!怎么解决这个芮存泄漏??
long g_ParsingParameters(PARAINFO& para, LPCTSTR prg_info, long svr_count, LPCTSTR svr_info, long url_count, LPCTSTR url_info, long ftp_count, LPCTSTR ftp_info)
//½âÎö²ÎÊýÐÅÏ¢
{
CString str, str1, str2;
CString tag;
LPTSTR pstr,pstr1,pstr2,ptag,p;
pstr=str.GetBuffer(1024);
pstr1=str1.GetBuffer(1024);
pstr2=str2.GetBuffer(1024);
ptag=tag.GetBuffer(1024);
int nStart, nEnd;
int i, nPos, nPos0, num;
para.bIsSchedule = FALSE;
//get program information
// str=prg_info;
strcpy(pstr,prg_info);
str.ReleaseBuffer();//ÓÃstrµÄ³ÉÔ±º¯ÊýǰҪÏÈReleaseBuffer
// tag = _T("NAME=");
strcpy(ptag,"NAME=");
tag.ReleaseBuffer();
nStart = str.Find(tag);
if (nStart == -1) return 1;
// tag = _T(";");
ptag=tag.GetBuffer(1024);
strcpy(ptag,";");
tag.ReleaseBuffer();
nEnd = str.Find(tag, nStart);
if (nEnd == -1) return 1;
strcpy(pstr2,str.Mid(nStart+5, nEnd-nStart-5));//1,不会泄漏
str2.ReleaseBuffer();//
str2.TrimLeft();
str2.TrimRight();
para.prg_info.name = str2;
//tag = _T("ID=");
ptag=tag.GetBuffer(1024);
strcpy(ptag,"ID=");
tag.ReleaseBuffer();
nStart = str.Find(tag);
if (nStart == -1) return 1;
#ifdef _DEBUG
CMemoryState oldMemState, newMemState, diffMemState;
oldMemState.Checkpoint();
#endif
// tag = _T(";");
ptag=tag.GetBuffer(1024);
strcpy(ptag,";");
tag.ReleaseBuffer();
nEnd = str.Find(tag, nStart);
if (nEnd == -1) return 1;
p=str2.GetBuffer(1024);
strcpy(p,str.Mid(nStart+3, nEnd-nStart-3));//2,这里泄漏!!why
str2.ReleaseBuffer();
str2.TrimLeft();
str2.TrimRight();
#ifdef _DEBUG
newMemState.Checkpoint();
if(diffMemState.Difference(oldMemState,newMemState))
{
TRACE("mem leak in RWF");
diffMemState.DumpStatistics();
}
#endif
。。。。
}
泄漏信息为:
0 bytes in 0 Free Blocks.
1037 bytes in 1 Normal Blocks.
0 bytes in 0 CRT Blocks.
0 bytes in 0 Ignore Blocks.
0 bytes in 0 Client Blocks.
Largest number used: 0 bytes.
Total allocations: 1065 bytes.