summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-29 14:25:23 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-29 14:57:44 +0200
commit28f18b68db1af3668203730ba8cfbb66103fe669 (patch)
tree9d639a077257394d7f1cef39deae14e180004ed6
parent9555d03c98346e7c1dc1443c8d8c3ac1b41bf678 (diff)
vcl: replace alloca() with std::unique_ptr
Change-Id: I82b982895ee422bcf5a23756df4d81c89bc47636
-rw-r--r--vcl/generic/fontmanager/fontconfig.cxx6
-rw-r--r--vcl/generic/fontmanager/fontmanager.cxx4
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx5
-rw-r--r--vcl/unx/generic/printer/jobdata.cxx7
4 files changed, 8 insertions, 14 deletions
diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx
index becb419399b3..f6ee508623c7 100644
--- a/vcl/generic/fontmanager/fontconfig.cxx
+++ b/vcl/generic/fontmanager/fontconfig.cxx
@@ -53,8 +53,6 @@ using namespace psp;
#include "rtl/ustrbuf.hxx"
-#include "sal/alloca.h"
-
#include <utility>
#include <algorithm>
@@ -1086,7 +1084,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
// update rMissingCodes by removing resolved unicodes
if( !rMissingCodes.isEmpty() )
{
- sal_uInt32* pRemainingCodes = static_cast<sal_uInt32*>(alloca( rMissingCodes.getLength() * sizeof(sal_uInt32) ));
+ std::unique_ptr<sal_uInt32[]> const pRemainingCodes(new sal_uInt32[rMissingCodes.getLength()]);
int nRemainingLen = 0;
FcCharSet* unicodes;
if (!FcPatternGetCharSet(pSet->fonts[0], FC_CHARSET, 0, &unicodes))
@@ -1099,7 +1097,7 @@ bool PrintFontManager::Substitute( FontSelectPattern &rPattern, OUString& rMissi
pRemainingCodes[ nRemainingLen++ ] = nCode;
}
}
- OUString sStillMissing(pRemainingCodes, nRemainingLen);
+ OUString sStillMissing(pRemainingCodes.get(), nRemainingLen);
#if defined(ENABLE_DBUS) && defined(ENABLE_PACKAGEKIT)
if (get_xid_for_dbus())
{
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index 56917f6ea1d4..b6651b7674ff 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -59,8 +59,6 @@
#include <stdio.h>
#endif
-#include "sal/alloca.h"
-
#include <algorithm>
#include <set>
#include <unordered_set>
@@ -472,7 +470,7 @@ bool PrintFontManager::PrintFont::readAfmMetrics( MultiAtomProvider* pProvider,
// first transform the character codes to unicode
// note: this only works with single byte encodings
- sal_Unicode* pUnicodes = static_cast<sal_Unicode*>(alloca( pInfo->numOfChars * sizeof(sal_Unicode)));
+ std::unique_ptr<sal_Unicode[]> const pUnicodes(new sal_Unicode[pInfo->numOfChars]);
CharMetricInfo* pChar = pInfo->cmi;
int i;
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 26b33ed02191..cd89bdf0e6a1 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -18,7 +18,6 @@
*/
#include <sal/types.h>
-#include <sal/alloca.h>
#include <vector>
@@ -244,7 +243,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt
// there is a matching fallback in the cache
// so update rMissingCodes with codepoints not yet resolved by this fallback
int nRemainingLength = 0;
- sal_UCS4* pRemainingCodes = static_cast<sal_UCS4*>(alloca( rMissingCodes.getLength() * sizeof(sal_UCS4) ));
+ std::unique_ptr<sal_UCS4[]> const pRemainingCodes(new sal_UCS4[rMissingCodes.getLength()]);
OUString aFontName;
while( nStrIndex < rMissingCodes.getLength() )
@@ -254,7 +253,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt
if( !bCached || (rFontSelData.maSearchName != aFontName) )
pRemainingCodes[ nRemainingLength++ ] = cChar;
}
- rMissingCodes = OUString( pRemainingCodes, nRemainingLength );
+ rMissingCodes = OUString( pRemainingCodes.get(), nRemainingLength );
}
else
{
diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx
index 85f587a3fe0d..840ef7b1b516 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -22,7 +22,6 @@
#include "vcl/printerinfomanager.hxx"
#include "tools/stream.hxx"
-#include <sal/alloca.h>
#include <rtl/strbuf.hxx>
#include <memory>
@@ -293,9 +292,9 @@ bool JobData::constructFromStreamBuffer( void* pData, int bytes, JobData& rJobDa
{
rJobData.m_aContext.setParser( rJobData.m_pParser );
int nBytes = bytes - aStream.Tell();
- char* pRemain = static_cast<char*>(alloca( bytes - aStream.Tell() ));
- aStream.Read( pRemain, nBytes );
- rJobData.m_aContext.rebuildFromStreamBuffer( pRemain, nBytes );
+ std::unique_ptr<char[]> pRemain(new char[bytes - aStream.Tell()]);
+ aStream.Read( pRemain.get(), nBytes );
+ rJobData.m_aContext.rebuildFromStreamBuffer( pRemain.get(), nBytes );
bContext = true;
}
}