Fixed auto_ptr<>.

This commit is contained in:
Vincent Richard 2013-11-21 23:04:27 +01:00
parent 03ea082f11
commit f00e5c4cd8

View File

@ -101,13 +101,13 @@ void charsetConverter_icu::convert(utility::inputStream& in, utility::outputStre
UChar* uOutBuffer = new UChar[outSize]; // Unicode chars end up here UChar* uOutBuffer = new UChar[outSize]; // Unicode chars end up here
// Auto delete Unicode char buffer // Auto delete Unicode char buffer
vmime::utility::auto_ptr<UChar> cleanup(uOutBuffer); std::auto_ptr<UChar> cleanup(uOutBuffer);
// To buffers // To buffers
// converted (char) data end up here // converted (char) data end up here
size_t cpOutBufferSz = ucnv_getMaxCharSize(m_to) * outSize; size_t cpOutBufferSz = ucnv_getMaxCharSize(m_to) * outSize;
char* cpOutBuffer = new char[cpOutBufferSz]; char* cpOutBuffer = new char[cpOutBufferSz];
vmime::utility::auto_ptr<char> cleanupOut(cpOutBuffer); std::auto_ptr<char> cleanupOut(cpOutBuffer);
// Set replacement chars for when converting from Unicode to codepage // Set replacement chars for when converting from Unicode to codepage
icu::UnicodeString substString(m_options.invalidSequence.c_str()); icu::UnicodeString substString(m_options.invalidSequence.c_str());
@ -259,7 +259,7 @@ void charsetFilteredOutputStream_icu::write
// Allocate buffer for Unicode chars // Allocate buffer for Unicode chars
size_t uniSize = ucnv_getMinCharSize(m_from) * count * sizeof(UChar); size_t uniSize = ucnv_getMinCharSize(m_from) * count * sizeof(UChar);
UChar* uniBuffer = new UChar[uniSize]; UChar* uniBuffer = new UChar[uniSize];
vmime::utility::auto_ptr <UChar> uniCleanup(uniBuffer); // auto delete Unicode buffer std::auto_ptr <UChar> uniCleanup(uniBuffer); // auto delete Unicode buffer
// Conversion loop // Conversion loop
UErrorCode toErr = U_ZERO_ERROR; UErrorCode toErr = U_ZERO_ERROR;
@ -289,7 +289,7 @@ void charsetFilteredOutputStream_icu::write
// Allocate buffer for destination charset // Allocate buffer for destination charset
size_t cpSize = ucnv_getMinCharSize(m_to) * uniLength; size_t cpSize = ucnv_getMinCharSize(m_to) * uniLength;
char* cpBuffer = new char[cpSize]; char* cpBuffer = new char[cpSize];
vmime::utility::auto_ptr <char> cpCleanup(cpBuffer); // auto delete CP buffer std::auto_ptr <char> cpCleanup(cpBuffer); // auto delete CP buffer
// Convert from Unicode to destination charset // Convert from Unicode to destination charset
UErrorCode fromErr = U_ZERO_ERROR; UErrorCode fromErr = U_ZERO_ERROR;
@ -332,7 +332,7 @@ void charsetFilteredOutputStream_icu::flush()
// Allocate buffer for Unicode chars // Allocate buffer for Unicode chars
size_t uniSize = ucnv_getMinCharSize(m_from) * 1024 * sizeof(UChar); size_t uniSize = ucnv_getMinCharSize(m_from) * 1024 * sizeof(UChar);
UChar* uniBuffer = new UChar[uniSize]; UChar* uniBuffer = new UChar[uniSize];
vmime::utility::auto_ptr <UChar> uniCleanup(uniBuffer); // auto delete Unicode buffer std::auto_ptr <UChar> uniCleanup(uniBuffer); // auto delete Unicode buffer
// Conversion loop (with flushing) // Conversion loop (with flushing)
UErrorCode toErr = U_ZERO_ERROR; UErrorCode toErr = U_ZERO_ERROR;
@ -362,7 +362,7 @@ void charsetFilteredOutputStream_icu::flush()
// Allocate buffer for destination charset // Allocate buffer for destination charset
size_t cpSize = ucnv_getMinCharSize(m_to) * uniLength; size_t cpSize = ucnv_getMinCharSize(m_to) * uniLength;
char* cpBuffer = new char[cpSize]; char* cpBuffer = new char[cpSize];
vmime::utility::auto_ptr <char> cpCleanup(cpBuffer); // auto delete CP buffer std::auto_ptr <char> cpCleanup(cpBuffer); // auto delete CP buffer
// Convert from Unicode to destination charset // Convert from Unicode to destination charset
UErrorCode fromErr = U_ZERO_ERROR; UErrorCode fromErr = U_ZERO_ERROR;