Article ID: 114201
Article Last Modified on 11/21/2006
class CMyString : public CString
{
public:
CMyString(const char* psz = NULL) : CString(psz) {}
void FreeExMem();
};
void CMyString::FreeExMem()
{
ASSERT(m_nDataLength<=m_nAllocLength);
if(!IsEmpty())
{
char *tp = new char[m_nDataLength+1];
memcpy(tp,m_pchData,m_nDataLength+1);
ASSERT(m_pchData[m_nDataLength]=='\0');
delete m_pchData;
m_pchData = tp;
m_nAllocLength = m_nDataLength;
}
ASSERT(m_pchData!=NULL);
}
void FreeExMem(CString &s)
{
if(!s.IsEmpty())
{
char *p = s.GetBuffer(1);
char *tp = new char[s.GetLength()+1];
memcpy(tp,p,s.GetLength()+1);
s.ReleaseBuffer();
s.Empty();
s = tp;
delete tp;
}
}
Additional query words: 1.00 1.50 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00
Keywords: kbbug kbvc500fix kbprb KB114201