From 8f3d411f46e1bdd1543633cf9b5a729cf89f79f3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Sep 2015 23:23:47 +0200 Subject: toolkit: convert alloca() to std::unique_ptr Change-Id: Ie50b4a1a189fffdaa6a0b26040c2e7c4cc42cd69 --- toolkit/source/awt/vclxfont.cxx | 5 ++--- toolkit/source/awt/vclxgraphics.cxx | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'toolkit/source') diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index a4b0c73a2d2a..acdae579408d 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -179,8 +178,8 @@ sal_Int32 VCLXFont::getStringWidthArray( const OUString& str, ::com::sun::star:: { vcl::Font aOldFont = pOutDev->GetFont(); pOutDev->SetFont( maFont ); - long* pDXA = static_cast(alloca(str.getLength() * sizeof(long))); - nRet = pOutDev->GetTextArray( str, pDXA ); + std::unique_ptr pDXA(new long[str.getLength()]); + nRet = pOutDev->GetTextArray( str, pDXA.get() ); rDXArray = ::com::sun::star::uno::Sequence( str.getLength() ); for(int i = 0; i < str.getLength(); i++) { diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx index 482e29c47021..4e2268f9dc73 100644 --- a/toolkit/source/awt/vclxgraphics.cxx +++ b/toolkit/source/awt/vclxgraphics.cxx @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -497,12 +496,12 @@ void VCLXGraphics::drawTextArray( sal_Int32 x, sal_Int32 y, const OUString& rTex if( mpOutputDevice ) { InitOutputDevice( InitOutDevFlags::CLIPREGION|InitOutDevFlags::RASTEROP|InitOutDevFlags::COLORS|InitOutDevFlags::FONT ); - long* pDXA = static_cast(alloca(rText.getLength() * sizeof(long))); + std::unique_ptr pDXA(new long[rText.getLength()]); for(int i = 0; i < rText.getLength(); i++) { pDXA[i] = rLongs[i]; } - mpOutputDevice->DrawTextArray( Point( x, y ), rText, pDXA ); + mpOutputDevice->DrawTextArray( Point( x, y ), rText, pDXA.get() ); } } -- cgit