Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CString::ReleaseBuffer
CString                                     Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  void ReleaseBuffer( int nNewLength = -1 );
 
  Parameter    Description
 
  <nNewLength> The new length of the string in characters, not counting a
               null terminator. If the string is null-terminated, the -1
               default value sets the CString size to the current length
               of the string.
 
  Remarks
 
  Use ReleaseBuffer to end use of a buffer allocated by GetBuffer.
 
  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,
  then use <nNewLength> to specify its length.
 
  The address returned by GetBuffer is invalid after the call to
  ReleaseBuffer or any other CString operation.
 
  Example
 
  CString s;
  char* p = s.GetBuffer( 1024 );
  s = "abc";
  ASSERT( s.GetLength() == 3 ); // String length = 3
  s.ReleaseBuffer();  // Surplus memory released, p is now invalid
  ASSERT( s.GetLength() == 3 ); // Length still 3
 
 
  See Also
 
  CString::GetBuffer
 
 
                                     -♦-