Export (0) Print
Expand All

CSimpleStringT::Preallocate

Allocates a specific amount of bytes for the CSimpleStringT object.

void Preallocate( 
   int nLength 
);

nLength

The exact size of the CSimpleStringT character buffer in characters.

Call this method to allocate a specific buffer size for the CSimpleStringT object.

CSimpleStringT generates a STATUS_NO_MEMORY exception if it is unable to allocate space for the character buffer. By default, memory allocation is performed by WIN32 API functions HeapAlloc or HeapReAlloc.

The following example demonstrates the use of CSimpleStringT::Preallocate.

CSimpleString str(pMgr);

_tprintf_s(_T("Allocated length: %d\n"), str.GetAllocLength());
str.Preallocate(100);
_tprintf_s(_T("Allocated length: %d\n"), str.GetAllocLength());

Header: atlsimpstr.h

Show:
© 2014 Microsoft