diff --git a/src/vmime/types.hpp b/src/vmime/types.hpp index 12e5bf71..7e5b7ee8 100644 --- a/src/vmime/types.hpp +++ b/src/vmime/types.hpp @@ -49,6 +49,7 @@ #include #include #include + #include #define VMIME_SHARED_PTR_NAMESPACE boost #else @@ -73,6 +74,12 @@ namespace vmime { void operator()(T*) const {} }; + +#if VMIME_SHARED_PTR_USE_CXX + template using scoped_ptr = std::unique_ptr ; +#else + using VMIME_SHARED_PTR_NAMESPACE::scoped_ptr; +#endif } #undef VMIME_SHARED_PTR_NAMESPACE diff --git a/src/vmime/word.cpp b/src/vmime/word.cpp index 2229857c..1a70a785 100644 --- a/src/vmime/word.cpp +++ b/src/vmime/word.cpp @@ -287,17 +287,17 @@ void word::parseImpl const string::const_iterator dataEnd = p; p += 2; // skip '?=' - utility::encoder::encoder* theEncoder = NULL; + scoped_ptr theEncoder; // Base-64 encoding if (*encPos == 'B' || *encPos == 'b') { - theEncoder = new utility::encoder::b64Encoder(); + theEncoder.reset(new utility::encoder::b64Encoder()); } // Quoted-Printable encoding else if (*encPos == 'Q' || *encPos == 'q') { - theEncoder = new utility::encoder::qpEncoder(); + theEncoder.reset(new utility::encoder::qpEncoder()); theEncoder->getProperties()["rfc2047"] = true; } @@ -325,7 +325,6 @@ void word::parseImpl utility::outputStreamStringAdapter eout(decodedBuffer); theEncoder->decode(ein, eout); - delete (theEncoder); m_buffer = decodedBuffer;