diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-12 14:17:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-13 09:28:44 +0200 |
commit | 639df4d76d545ca23021f69a9d738a9a92c148cd (patch) | |
tree | 87b20ea1518f6a878102a367c211cb6f93c554fd | |
parent | 9dce6f74b1b43293b40217c1163c8d4285251e97 (diff) |
use more std::make_unique
Change-Id: I7d85cbc9105c5e0c4a8d9a69c4ac9d6dfc07eabd
Reviewed-on: https://gerrit.libreoffice.org/70663
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
20 files changed, 25 insertions, 25 deletions
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index fb0369d7c8cc..9b6e755f93e7 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -173,7 +173,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe SUCCEEDED( pDet->GetBitmapBits( 0, &nSize, nullptr, nWidth, nHeight ) ) && ( nSize > 0 ) ) { - auto pBuffer = std::unique_ptr<char[]>(new char[ nSize ]); + auto pBuffer = std::make_unique<char[]>(nSize); try { 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 385f5f5cb9ed..8d49ff6dafd1 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -593,7 +593,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 - auto exceptionTypeSizeArray = std::unique_ptr<int[]>(new int[nLen]); + auto exceptionTypeSizeArray = std::make_unique<int[]>(nLen); nLen = 0; for (pCompTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD); diff --git a/desktop/source/deployment/misc/lockfile.cxx b/desktop/source/deployment/misc/lockfile.cxx index b46da255647b..ff216ff7f9dc 100644 --- a/desktop/source/deployment/misc/lockfile.cxx +++ b/desktop/source/deployment/misc/lockfile.cxx @@ -54,7 +54,7 @@ static OString impl_getHostname() hostname by using the netbios name */ DWORD sz = MAX_COMPUTERNAME_LENGTH + 1; - auto szHost = std::unique_ptr<char[]>(new char[sz]); + auto szHost = std::make_unique<char[]>(sz); if (GetComputerNameA(szHost.get(), &sz)) aHost = OString(szHost.get()); else diff --git a/fpicker/source/win32/FilterContainer.cxx b/fpicker/source/win32/FilterContainer.cxx index 678c8791d5b7..67ccd6353ba3 100644 --- a/fpicker/source/win32/FilterContainer.cxx +++ b/fpicker/source/win32/FilterContainer.cxx @@ -239,7 +239,7 @@ OUString makeWinFilterBuffer( CFilterContainer& aFilterContainer ) if ( !reqBuffSize ) return OUString( ); - auto pBuff = std::unique_ptr<sal_Unicode[]>(new sal_Unicode[reqBuffSize]); + auto pBuff = std::make_unique<sal_Unicode[]>(reqBuffSize); // initialize the buffer with 0 ZeroMemory( pBuff.get(), sizeof( sal_Unicode ) * reqBuffSize ); diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 247e13c2450e..1221b056c2a3 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -973,7 +973,7 @@ static gboolean postDocumentLoad(gpointer pData) // Total number of columns in this document. guint nColumns = ceil(static_cast<double>(nDocumentWidthPixels) / nTileSizePixels); - priv->m_pTileBuffer = std::unique_ptr<TileBuffer>(new TileBuffer(nColumns)); + priv->m_pTileBuffer = std::make_unique<TileBuffer>(nColumns); gtk_widget_set_size_request(GTK_WIDGET(pLOKDocView), nDocumentWidthPixels, nDocumentHeightPixels); @@ -3485,7 +3485,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) // Total number of columns in this document. guint nColumns = ceil(static_cast<double>(nDocumentWidthPixels) / nTileSizePixels); - priv->m_pTileBuffer = std::unique_ptr<TileBuffer>(new TileBuffer(nColumns)); + priv->m_pTileBuffer = std::make_unique<TileBuffer>(nColumns); gtk_widget_set_size_request(GTK_WIDGET(pDocView), nDocumentWidthPixels, nDocumentHeightPixels); diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx index 07a315f36be2..ae1670c30b92 100644 --- a/sal/osl/unx/backtraceapi.cxx +++ b/sal/osl/unx/backtraceapi.cxx @@ -42,7 +42,7 @@ OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth) { if (maxDepth > maxInt) { maxDepth = static_cast<sal_uInt32>(maxInt); } - auto b1 = std::unique_ptr<void *[]>(new void *[maxDepth]); + auto b1 = std::make_unique<void *[]>(maxDepth); int n = backtrace(b1.get(), static_cast<int>(maxDepth)); FreeGuard b2(backtrace_symbols(b1.get(), n)); b1.reset(); diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index b3af7fd0b5ed..5026d65de397 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -718,7 +718,7 @@ void ScBroadcastAreaSlotMachine::StartListeningArea( { TableSlotsMap::iterator iTab( aTableSlotsMap.find( nTab)); if (iTab == aTableSlotsMap.end()) - iTab = aTableSlotsMap.emplace(nTab, std::unique_ptr<TableSlots>(new TableSlots)).first; + iTab = aTableSlotsMap.emplace(nTab, std::make_unique<TableSlots>()).first; ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots(); SCSIZE nStart, nEnd, nRowBreak; ComputeAreaPoints( rRange, nStart, nEnd, nRowBreak ); @@ -1029,7 +1029,7 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas( { TableSlotsMap::iterator iTab( aTableSlotsMap.find( nTab)); if (iTab == aTableSlotsMap.end()) - iTab = aTableSlotsMap.emplace(nTab, std::unique_ptr<TableSlots>(new TableSlots)).first; + iTab = aTableSlotsMap.emplace(nTab, std::make_unique<TableSlots>()).first; ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots(); SCSIZE nStart, nEnd, nRowBreak; ComputeAreaPoints( aRange, nStart, nEnd, nRowBreak ); diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 2e41dbb40dc1..55e309c959df 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -990,7 +990,7 @@ void ScUndoRangeNames::DoChange( bool bUndo ) if ( bUndo ) { - auto p = std::unique_ptr<ScRangeName>(new ScRangeName( *pOldRanges )); + auto p = std::make_unique<ScRangeName>(*pOldRanges); if (mnTab >= 0) rDoc.SetRangeName( mnTab, std::move(p) ); else @@ -998,7 +998,7 @@ void ScUndoRangeNames::DoChange( bool bUndo ) } else { - auto p = std::unique_ptr<ScRangeName>(new ScRangeName( *pNewRanges )); + auto p = std::make_unique<ScRangeName>(*pNewRanges); if (mnTab >= 0) rDoc.SetRangeName( mnTab, std::move(p) ); else diff --git a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx index 603495de817e..5ddd6413fce0 100644 --- a/shell/source/win32/shlxthandler/propsheets/propsheets.cxx +++ b/shell/source/win32/shlxthandler/propsheets/propsheets.cxx @@ -131,7 +131,7 @@ HRESULT STDMETHODCALLTYPE CPropertySheet::Initialize( UINT size = DragQueryFileW( static_cast<HDROP>(medium.hGlobal), 0, nullptr, 0 ); if ( size != 0 ) { - auto buffer = std::unique_ptr<WCHAR[]>(new WCHAR[ size + 1 ]); + auto buffer = std::make_unique<WCHAR[]>( size + 1 ); UINT result_size = DragQueryFileW( static_cast<HDROP>(medium.hGlobal), 0, buffer.get(), size + 1 ); if ( result_size != 0 ) diff --git a/shell/source/win32/shlxthandler/util/utilities.cxx b/shell/source/win32/shlxthandler/util/utilities.cxx index 2f498daae5c5..80bd6a1cb4fa 100644 --- a/shell/source/win32/shlxthandler/util/utilities.cxx +++ b/shell/source/win32/shlxthandler/util/utilities.cxx @@ -125,7 +125,7 @@ std::wstring getShortPathName( const std::wstring& aLongName ) if ( length != 0 ) { - auto buffer = std::unique_ptr<WCHAR[]>(new WCHAR[ length+1 ]); + auto buffer = std::make_unique<WCHAR[]>( length+1 ); length = GetShortPathNameW( aLongName.c_str(), buffer.get(), length ); if ( length != 0 ) shortName = std::wstring( buffer.get() ); diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx index 05856e1c8198..9de4b047a976 100644 --- a/shell/source/win32/zipfile/zipfile.cxx +++ b/shell/source/win32/zipfile/zipfile.cxx @@ -130,7 +130,7 @@ std::string readString(StreamInterface *stream, unsigned long size) { if (!stream || stream->stell() == -1) throw IOException(-1); - auto tmp = std::unique_ptr<unsigned char[]>(new unsigned char[size]); + auto tmp = std::make_unique<unsigned char[]>(size); unsigned long numBytesRead = stream->sread(tmp.get(), size); if (numBytesRead != size) { diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index cb1fd8be147d..d64df8742259 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -93,7 +93,7 @@ HDDEDATA CALLBACK DdeInternal::SvrCallback( if( !nTopics ) return nullptr; - auto pPairs = std::unique_ptr<HSZPAIR[]>(new HSZPAIR [nTopics + 1]); + auto pPairs = std::make_unique<HSZPAIR[]>(nTopics + 1); HSZPAIR* q = pPairs.get(); for (auto& rpService : rAll) diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index 4f5d18c7eb85..93c37f7a426f 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -971,7 +971,7 @@ void Qt5Frame::UpdateSettings(AllSettings& rSettings) style.SetCursorBlinkTime(flash_time != 0 ? flash_time / 2 : STYLE_CURSOR_NOBLINKTIME); // Menu - std::unique_ptr<QMenuBar> pMenuBar = std::unique_ptr<QMenuBar>(new QMenuBar()); + std::unique_ptr<QMenuBar> pMenuBar = std::make_unique<QMenuBar>(); QPalette qMenuCG = pMenuBar->palette(); // Menu text and background color, theme specific diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx index 075408df88c8..67f82f782195 100644 --- a/vcl/source/image/ImplImageTree.cxx +++ b/vcl/source/image/ImplImageTree.cxx @@ -520,7 +520,7 @@ ImplImageTree::IconCache &ImplImageTree::getIconCache(const ImageRequestParamete auto it = rSet.maScaledIconCaches.find(rParameters.mnScalePercentage); if ( it != rSet.maScaledIconCaches.end() ) return *it->second.get(); - rSet.maScaledIconCaches[rParameters.mnScalePercentage] = std::unique_ptr<IconCache>(new IconCache); + rSet.maScaledIconCaches[rParameters.mnScalePercentage] = std::make_unique<IconCache>(); return *rSet.maScaledIconCaches[rParameters.mnScalePercentage].get(); } diff --git a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx index a2ea6b7bbefd..47289d49cf27 100644 --- a/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx +++ b/vcl/unx/gtk3_kde5/kde5_filepicker_ipc.cxx @@ -214,7 +214,7 @@ FilePickerIpc::FilePickerIpc(KDE5FilePicker* filePicker, QObject* parent) // read IPC commands and their args in a separate thread, so this does not block everything else; // 'commandReceived' signal is emitted every time a command and its args have been read; // thread will run until the filepicker process is terminated - m_ipcReaderThread = std::unique_ptr<std::thread>{ new std::thread(readCommands, this) }; + m_ipcReaderThread = std::make_unique<std::thread>{ readCommands, this }; } FilePickerIpc::~FilePickerIpc() diff --git a/vcl/unx/kde5/KDE5SalFrame.cxx b/vcl/unx/kde5/KDE5SalFrame.cxx index d3a13968237f..cae8bd843423 100644 --- a/vcl/unx/kde5/KDE5SalFrame.cxx +++ b/vcl/unx/kde5/KDE5SalFrame.cxx @@ -194,7 +194,7 @@ void KDE5SalFrame::UpdateSettings(AllSettings& rSettings) style.SetCursorBlinkTime(flash_time != 0 ? flash_time / 2 : STYLE_CURSOR_NOBLINKTIME); // Menu - std::unique_ptr<QMenuBar> pMenuBar = std::unique_ptr<QMenuBar>(new QMenuBar()); + std::unique_ptr<QMenuBar> pMenuBar = std::make_unique<QMenuBar>(); aFont = toFont(pMenuBar->font(), rSettings.GetUILanguageTag().getLocale()); style.SetMenuFont(aFont); diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx index 9f729a14bdde..8119bad8cdb7 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -1205,7 +1205,7 @@ OUString WinSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, sal DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, nullptr, pSetupData ); if ( (nPaperBin < nBins) && (nBins != GDI_ERROR) ) { - auto pBuffer = std::unique_ptr<sal_Unicode[]>(new sal_Unicode[nBins*24]); + auto pBuffer = std::make_unique<sal_Unicode[]>(nBins*24); DWORD nRet = ImplDeviceCaps( this, DC_BINNAMES, reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData ); if ( nRet && (nRet != GDI_ERROR) ) aPaperBinName = OUString( pBuffer.get() + (nPaperBin*24) ); diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 16cdf0e8579f..bf2c15bca26d 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -4967,7 +4967,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, LONG nTextLen = ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, nullptr, 0 ) / sizeof( WCHAR ); if ( nTextLen >= 0 ) { - auto pTextBuf = std::unique_ptr<WCHAR[]>(new WCHAR[nTextLen]); + auto pTextBuf = std::make_unique<WCHAR[]>(nTextLen); ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), static_cast<sal_Int32>(nTextLen) ); } @@ -4993,7 +4993,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, if ( nTextLen > 0 ) { { - auto pTextBuf = std::unique_ptr<WCHAR[]>(new WCHAR[nTextLen]); + auto pTextBuf = std::make_unique<WCHAR[]>(nTextLen); ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), static_cast<sal_Int32>(nTextLen) ); } diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx index 4b6ef98cf905..8c58ffada322 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx @@ -69,7 +69,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); - auto arrCertAltNameEntry = std::unique_ptr<CertAltNameEntry[]>(new CertAltNameEntry[subjectName->cAltEntry]); + auto arrCertAltNameEntry = std::make_unique<CertAltNameEntry[]>(subjectName->cAltEntry); for (unsigned int i = 0; i < static_cast<unsigned int>(subjectName->cAltEntry); i++){ PCERT_ALT_NAME_ENTRY pEntry = &subjectName->rgAltEntry[i]; diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index d44d093641c1..17c8eea1b71b 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -213,7 +213,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getIssuerName() { // Here the cbIssuer count the last 0x00 , take care. if( cchIssuer != 0 ) { - auto issuer = std::unique_ptr<wchar_t[]>(new wchar_t[ cchIssuer ]); + auto issuer = std::make_unique<wchar_t[]>(cchIssuer); cchIssuer = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , @@ -251,7 +251,7 @@ OUString SAL_CALL X509Certificate_MSCryptImpl::getSubjectName() if( cchSubject != 0 ) { - auto subject = std::unique_ptr<wchar_t[]>(new wchar_t[ cchSubject ]); + auto subject = std::make_unique<wchar_t[]>(cchSubject); cchSubject = CertNameToStrW( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING , |