Share via


CSimpleStringT::FreeExtra

이전에 문자열을 할당 했지만 더 이상 필요는 여분의 메모리를 해제 합니다.

void FreeExtra( );

설명

이 문자열 개체가 사용한 메모리 오버 헤드를 줄여야 합니다.메서드는 정확한 길이 반환 하는 버퍼를 다시 할당 GetLength.

예제

CAtlString basestr;
IAtlStringMgr* pMgr;

pMgr= basestr.GetManager();
ASSERT(pMgr != NULL);

// Create a CSimpleString with 28 characters
CSimpleString str(_T("Many sports are fun to play."), 28, pMgr);
_tprintf_s(_T("Alloc length is %d, String length is %d\n"),
   str.GetAllocLength(), str.GetLength());

// Assigning a smaller string won't cause CSimpleString to free its
// memory, because it assumes the string will grow again anyway.
str = _T("Soccer is best!");
_tprintf_s(_T("Alloc length is %d, String length is %d\n"),
   str.GetAllocLength(), str.GetLength());

// This call forces CSimpleString to release the extra
// memory it doesn't need.
str.FreeExtra();
_tprintf_s(_T("Alloc length is %d, String length is %d\n"),
   str.GetAllocLength(), str.GetLength());

설명

이 예제에서 출력은 다음과 같습니다.

Alloc length is 1031, String length is 1024

Alloc length is 1031, String length is 15

Alloc length is 15, String length is 15

요구 사항

헤더: atlsimpstr.h

참고 항목

참조

CSimpleStringT 클래스