Releases control of the buffer allocated by GetBuffer.
Call this method to reallocate or free up the buffer of the string object. If you know that the string in the buffer is null terminated, you can omit the nNewLength argument. If your string is not null terminated, use nNewLength to specify its length. The address returned by GetBuffer is invalid after the call to ReleaseBuffer or any other CSimpleStringT operation.
The following example demonstrates the use of CSimpleStringT::ReleaseBuffer.
const int bufferSize = 1024; CSimpleString s(_T("abc"), pMgr); LPTSTR p = s.GetBuffer(bufferSize); _tcscpy_s(p, bufferSize , _T("abc")); // use the buffer directly ASSERT(s.GetLength() == 3); // String length = 3 s.ReleaseBuffer(); // Surplus memory released, p is now invalid. ASSERT(s.GetLength() == 3); // Length still 3