CSimpleStringT::FreeExtra

Libera a qualquer memória extra anteriormente distribuído pela seqüência de caracteres, mas não mais necessários.

void FreeExtra( );

Comentários

Isso deve reduzir a sobrecarga de memória consumida pelo objeto de cadeia de caracteres.O método realoca o buffer para o comprimento exato retornado por GetLength.

Exemplo

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());

Comentários

A saída deste exemplo é sistema autônomo segue:

Alloc length is 1031, String length is 1024

Alloc length is 1031, String length is 15

Alloc length is 15, String length is 15

Requisitos

Cabeçalho: atlsimpstr.h

Consulte também

Referência

Classe CSimpleStringT

Outros recursos

CSimpleStringT membros