summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--avmedia/source/win/framegrabber.cxx12
-rw-r--r--basic/source/runtime/methods.cxx3
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx8
-rw-r--r--configmgr/source/winreg.cxx18
-rw-r--r--sfx2/source/doc/graphhelp.cxx12
-rw-r--r--shell/source/win32/shlxthandler/propsheets/propsheets.cxx8
-rw-r--r--vcl/win/gdi/salprn.cxx10
-rw-r--r--vcl/win/window/salframe.cxx8
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx9
9 files changed, 46 insertions, 42 deletions
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx
index 3d1f5906e2fc..ce24b96f7ad2 100644
--- a/avmedia/source/win/framegrabber.cxx
+++ b/avmedia/source/win/framegrabber.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <memory>
+
#if defined _MSC_VER
#pragma warning(push, 1)
#pragma warning(disable: 4917)
@@ -170,13 +174,13 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe
SUCCEEDED( pDet->GetBitmapBits( 0, &nSize, nullptr, nWidth, nHeight ) ) &&
( nSize > 0 ) )
{
- char* pBuffer = new char[ nSize ];
+ auto pBuffer = std::unique_ptr<char[]>(new char[ nSize ]);
try
{
- if( SUCCEEDED( pDet->GetBitmapBits( fMediaTime, nullptr, pBuffer, nWidth, nHeight ) ) )
+ if( SUCCEEDED( pDet->GetBitmapBits( fMediaTime, nullptr, pBuffer.get(), nWidth, nHeight ) ) )
{
- SvMemoryStream aMemStm( pBuffer, nSize, StreamMode::READ | StreamMode::WRITE );
+ SvMemoryStream aMemStm( pBuffer.get(), nSize, StreamMode::READ | StreamMode::WRITE );
Bitmap aBmp;
if( ReadDIB(aBmp, aMemStm, false ) && !aBmp.IsEmpty() )
@@ -189,8 +193,6 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe
catch( ... )
{
}
-
- delete [] pBuffer;
}
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 1a4c12b4f1bb..3447bff32949 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -419,7 +419,7 @@ RTLFUNC(CurDir)
}
}
}
- char* pBuffer = new char[ _MAX_PATH ];
+ char pBuffer[ _MAX_PATH ];
if ( _getdcwd( nCurDir, pBuffer, _MAX_PATH ) != nullptr )
{
rPar.Get(0)->PutString( OUString::createFromAscii( pBuffer ) );
@@ -428,7 +428,6 @@ RTLFUNC(CurDir)
{
StarBASIC::Error( ERRCODE_BASIC_NO_DEVICE );
}
- delete [] pBuffer;
#else
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
index 15a12d58fc77..180828b69c3f 100644
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx
@@ -236,6 +236,9 @@ void
#pragma warning( disable : 4237 )
#include <sal/config.h>
+
+#include <memory>
+
#include <malloc.h>
#include <new.h>
#include <typeinfo.h>
@@ -617,7 +620,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
// 2.Pass: Get the total needed memory for class ExceptionType
// (with embedded type_info) and keep the sizes for each instance
// is stored in allocated int array
- int *exceptionTypeSizeArray = new int[nLen];
+ auto exceptionTypeSizeArray = std::unique_ptr<int[]>(new int[nLen]);
nLen = 0;
for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
@@ -697,9 +700,6 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw ()
}
// Final check: end of address calculation must be end of mem
assert(etMem + etMemOffset == pCode + totalSize);
-
- // remove array
- delete[] exceptionTypeSizeArray;
}
#if !defined LEAK_STATIC_DATA
diff --git a/configmgr/source/winreg.cxx b/configmgr/source/winreg.cxx
index c2e709b15686..60f99f1a911f 100644
--- a/configmgr/source/winreg.cxx
+++ b/configmgr/source/winreg.cxx
@@ -9,6 +9,8 @@
*/
#include <cwchar>
+#include <memory>
+
#ifdef _MSC_VER
#pragma warning(push, 1) /* disable warnings within system headers */
#endif
@@ -103,8 +105,10 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil
else if(nValues)
{
// No more subkeys, we are at a leaf
- wchar_t* pValueName = new wchar_t[nLongestValueNameLen + 1];
- wchar_t* pValue = new wchar_t[nLongestValueLen + 1];
+ auto pValueName = std::unique_ptr<wchar_t[]>(
+ new wchar_t[nLongestValueNameLen + 1]);
+ auto pValue = std::unique_ptr<wchar_t[]>(
+ new wchar_t[nLongestValueLen + 1]);
bool bFinal = false;
OUString aValue;
@@ -114,13 +118,13 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil
DWORD nValueNameLen = nLongestValueNameLen + 1;
DWORD nValueLen = nLongestValueLen + 1;
- RegEnumValueW(hCurKey, i, pValueName, &nValueNameLen, nullptr, nullptr, reinterpret_cast<LPBYTE>(pValue), &nValueLen);
+ RegEnumValueW(hCurKey, i, pValueName.get(), &nValueNameLen, nullptr, nullptr, reinterpret_cast<LPBYTE>(pValue.get()), &nValueLen);
const wchar_t wsValue[] = L"Value";
const wchar_t wsFinal[] = L"Final";
- if(!wcscmp(pValueName, wsValue))
- aValue = OUString(pValue);
- if(!wcscmp(pValueName, wsFinal) && *reinterpret_cast<DWORD*>(pValue) == 1)
+ if(!wcscmp(pValueName.get(), wsValue))
+ aValue = OUString(pValue.get());
+ if(!wcscmp(pValueName.get(), wsFinal) && *reinterpret_cast<DWORD*>(pValue.get()) == 1)
bFinal = true;
}
sal_Int32 aLastSeparator = aKeyName.lastIndexOf('\\');
@@ -177,8 +181,6 @@ void dumpWindowsRegistryKey(HKEY hKey, OUString const & aKeyName, TempFile &aFil
for(; nCloseNode > 0; nCloseNode--)
writeData(aFileHandle, "</node>");
writeData(aFileHandle, "</item>\n");
- delete[] pValueName;
- delete[] pValue;
}
RegCloseKey(hCurKey);
}
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx
index 542c8ff4aef2..f6ab18cc1645 100644
--- a/sfx2/source/doc/graphhelp.cxx
+++ b/sfx2/source/doc/graphhelp.cxx
@@ -118,17 +118,17 @@ void* GraphicHelper::getWinMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta, co
#ifdef _WIN32
if ( pGDIMeta )
{
- SvMemoryStream* pStream = new SvMemoryStream( 65535, 65535 );
+ SvMemoryStream pStream( 65535, 65535 );
Graphic aGraph( *pGDIMeta );
- bool bFailed = GraphicConverter::Export( *pStream, aGraph, ConvertDataFormat::WMF );
- pStream->Flush();
+ bool bFailed = GraphicConverter::Export( pStream, aGraph, ConvertDataFormat::WMF );
+ pStream.Flush();
if ( !bFailed )
{
- sal_Int32 nLength = pStream->Seek( STREAM_SEEK_TO_END );
+ sal_Int32 nLength = pStream.Seek( STREAM_SEEK_TO_END );
if ( nLength > 22 )
{
HMETAFILE hMeta = SetMetaFileBitsEx( nLength - 22,
- ( static_cast< const unsigned char*>( pStream->GetData() ) ) + 22 );
+ ( static_cast< const unsigned char*>( pStream.GetData() ) ) + 22 );
if ( hMeta )
{
@@ -166,8 +166,6 @@ void* GraphicHelper::getWinMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta, co
}
}
}
-
- delete pStream;
}
#endif
diff --git a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
index 9d524e990d00..1ac28c349319 100644
--- a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
+++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx
@@ -36,6 +36,7 @@
#pragma warning(pop)
#endif
+#include <memory>
#include <string>
#include <vector>
#include <utility>
@@ -139,12 +140,12 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize(
UINT size = DragQueryFileW( static_cast<HDROP>(medium.hGlobal), 0, nullptr, 0 );
if ( size != 0 )
{
- WCHAR * buffer = new WCHAR[ size + 1 ];
+ auto buffer = std::unique_ptr<WCHAR[]>(new WCHAR[ size + 1 ]);
UINT result_size = DragQueryFileW( static_cast<HDROP>(medium.hGlobal),
- 0, buffer, size + 1 );
+ 0, buffer.get(), size + 1 );
if ( result_size != 0 )
{
- std::wstring fname = getShortPathName( buffer );
+ std::wstring fname = getShortPathName( buffer.get() );
std::string fnameA = WStringToString( fname );
ZeroMemory( m_szFileName, sizeof( m_szFileName ) );
strncpy( m_szFileName, fnameA.c_str(), ( sizeof( m_szFileName ) - 1 ) );
@@ -152,7 +153,6 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize(
}
else
hr = E_INVALIDARG;
- delete [] buffer;
}
else
hr = E_INVALIDARG;
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index db54dd0069f0..60b5320f7c8b 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <memory>
#include <string.h>
#include <svsys.h>
@@ -1220,11 +1223,10 @@ OUString WinSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, sal
DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, nullptr, pSetupData );
if ( (nPaperBin < nBins) && (nBins != GDI_ERROR) )
{
- sal_Unicode* pBuffer = new sal_Unicode[nBins*24];
- DWORD nRet = ImplDeviceCaps( this, DC_BINNAMES, reinterpret_cast<BYTE*>(pBuffer), pSetupData );
+ auto pBuffer = std::unique_ptr<sal_Unicode[]>(new sal_Unicode[nBins*24]);
+ DWORD nRet = ImplDeviceCaps( this, DC_BINNAMES, reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
if ( nRet && (nRet != GDI_ERROR) )
- aPaperBinName = OUString( pBuffer + (nPaperBin*24) );
- delete [] pBuffer;
+ aPaperBinName = OUString( pBuffer.get() + (nPaperBin*24) );
}
return aPaperBinName;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 689a69c0699c..d908dbc7f854 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -26,6 +26,7 @@
#include <officecfg/Office/Common.hxx>
+#include <memory>
#include <string.h>
#include <limits.h>
@@ -5010,10 +5011,9 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame,
LONG nTextLen = ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, nullptr, 0 ) / sizeof( WCHAR );
if ( nTextLen >= 0 )
{
- WCHAR* pTextBuf = new WCHAR[nTextLen];
- ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf, nTextLen*sizeof( WCHAR ) );
- aEvt.maText = OUString( reinterpret_cast<const sal_Unicode*>(pTextBuf), (sal_Int32)nTextLen );
- delete [] pTextBuf;
+ auto pTextBuf = std::unique_ptr<WCHAR[]>(new WCHAR[nTextLen]);
+ ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) );
+ aEvt.maText = OUString( reinterpret_cast<const sal_Unicode*>(pTextBuf.get()), (sal_Int32)nTextLen );
}
aEvt.mnCursorPos = aEvt.maText.getLength();
diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx
index 5fba1ff146d3..35f32424d409 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx
@@ -18,6 +18,9 @@
*/
#include <sal/config.h>
+
+#include <memory>
+
#include <rtl/uuid.h>
#include <rtl/ustring.hxx>
#include <com/sun/star/security/ExtAltNameType.hpp>
@@ -65,7 +68,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
DWORD size;
CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ALTERNATE_NAME, reinterpret_cast<unsigned char*>(m_xExtnValue.getArray()), m_xExtnValue.getLength(), CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, nullptr,&subjectName, &size);
- CertAltNameEntry* arrCertAltNameEntry = new CertAltNameEntry[subjectName->cAltEntry];
+ auto arrCertAltNameEntry = std::unique_ptr<CertAltNameEntry[]>(new CertAltNameEntry[subjectName->cAltEntry]);
for (unsigned int i = 0; i < (unsigned int)subjectName->cAltEntry; i++){
PCERT_ALT_NAME_ENTRY pEntry = &subjectName->rgAltEntry[i];
@@ -122,9 +125,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl:
break;
}
}
- m_Entries = ::comphelper::arrayToSequence< css::security::CertAltNameEntry >(arrCertAltNameEntry, subjectName->cAltEntry);
-
- delete [] arrCertAltNameEntry;
+ m_Entries = ::comphelper::arrayToSequence< css::security::CertAltNameEntry >(arrCertAltNameEntry.get(), subjectName->cAltEntry);
}
return m_Entries;