summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-28 23:42:27 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-29 14:57:41 +0200
commit2c9a1811fcd7f155226b315fc91811ba195c2c57 (patch)
tree2316b96e3bf9eb3362d29e265023044fc2457eb2 /vcl/source
parent8f3d411f46e1bdd1543633cf9b5a729cf89f79f3 (diff)
vcl: replace alloca() with std::unique_ptr
Change-Id: I73d27e0e5a8ad0a02579c43f3fd479cb374d6bbd
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/sallayout.cxx25
1 files changed, 12 insertions, 13 deletions
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 3fcf3c62b21b..04cbdd2e7c30 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -25,7 +25,6 @@
#include <cstdio>
#include <math.h>
-#include <sal/alloca.h>
#include <salgdi.hxx>
#include <sallayout.hxx>
@@ -995,7 +994,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
// determine cluster boundaries and x base offset
const int nCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
- int* pLogCluster = static_cast<int*>(alloca( nCharCount * sizeof(int) ));
+ std::unique_ptr<int[]> const pLogCluster(new int[nCharCount]);
size_t i;
int n,p;
long nBasePointX = -1;
@@ -1030,7 +1029,7 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
}
// calculate adjusted cluster widths
- long* pNewGlyphWidths = static_cast<long*>(alloca( m_GlyphItems.size() * sizeof(long) ));
+ std::unique_ptr<long[]> const pNewGlyphWidths(new long[m_GlyphItems.size()]);
for( i = 0; i < m_GlyphItems.size(); ++i )
pNewGlyphWidths[ i ] = 0;
@@ -1294,8 +1293,8 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co
sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
{
int nCharCapacity = mnEndCharPos - mnMinCharPos;
- DeviceCoordinate* pCharWidths = static_cast<DeviceCoordinate*>(alloca( nCharCapacity * sizeof(DeviceCoordinate) ));
- if( !GetCharWidths( pCharWidths ) )
+ std::unique_ptr<DeviceCoordinate[]> const pCharWidths(new DeviceCoordinate[nCharCapacity]);
+ if (!GetCharWidths(pCharWidths.get()))
return -1;
DeviceCoordinate nWidth = 0;
@@ -1929,13 +1928,13 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi
return mpLayouts[0]->GetTextBreak( nMaxWidth, nCharExtra, nFactor );
int nCharCount = mnEndCharPos - mnMinCharPos;
- DeviceCoordinate* pCharWidths = static_cast<DeviceCoordinate*>(alloca( 2*nCharCount * sizeof(DeviceCoordinate) ));
- mpLayouts[0]->FillDXArray( pCharWidths );
+ std::unique_ptr<DeviceCoordinate[]> const pCharWidths(new DeviceCoordinate[2 * nCharCount]);
+ mpLayouts[0]->FillDXArray( pCharWidths.get() );
for( int n = 1; n < mnLevel; ++n )
{
SalLayout& rLayout = *mpLayouts[ n ];
- rLayout.FillDXArray( pCharWidths + nCharCount );
+ rLayout.FillDXArray( &pCharWidths[nCharCount] );
double fUnitMul = mnUnitsPerPixel;
fUnitMul /= rLayout.GetUnitsPerPixel();
for( int i = 0; i < nCharCount; ++i )
@@ -1963,19 +1962,19 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co
DeviceCoordinate nMaxWidth = 0;
// prepare merging of fallback levels
- DeviceCoordinate* pTempWidths = NULL;
+ std::unique_ptr<DeviceCoordinate[]> pTempWidths;
const int nCharCount = mnEndCharPos - mnMinCharPos;
if( pCharWidths )
{
for( int i = 0; i < nCharCount; ++i )
pCharWidths[i] = 0;
- pTempWidths = static_cast<DeviceCoordinate*>(alloca( nCharCount * sizeof(DeviceCoordinate) ));
+ pTempWidths.reset(new DeviceCoordinate[nCharCount]);
}
for( int n = mnLevel; --n >= 0; )
{
// query every fallback level
- DeviceCoordinate nTextWidth = mpLayouts[n]->FillDXArray( pTempWidths );
+ DeviceCoordinate nTextWidth = mpLayouts[n]->FillDXArray( pTempWidths.get() );
if( !nTextWidth )
continue;
// merge results from current level
@@ -2011,10 +2010,10 @@ void MultiSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) cons
if( mnLevel > 1 )
{
- long* pTempPos = static_cast<long*>(alloca( nMaxIndex * sizeof(long) ));
+ std::unique_ptr<long[]> const pTempPos(new long[nMaxIndex]);
for( int n = 1; n < mnLevel; ++n )
{
- mpLayouts[ n ]->GetCaretPositions( nMaxIndex, pTempPos );
+ mpLayouts[ n ]->GetCaretPositions( nMaxIndex, pTempPos.get() );
double fUnitMul = mnUnitsPerPixel;
fUnitMul /= mpLayouts[n]->GetUnitsPerPixel();
for( int i = 0; i < nMaxIndex; ++i )