cppcheck: allocaCalled

Change-Id: I253f71f851621d8a3d1244468b9da63ba2d10b09
This commit is contained in:
Caolán McNamara
2016-01-02 20:27:09 +00:00
parent f61d3bc92c
commit aa330a9ddc
2 changed files with 11 additions and 39 deletions

View File

@@ -35,7 +35,6 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <vcl/canvastools.hxx> #include <vcl/canvastools.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <sal/alloca.h>
#include <com/sun/star/rendering/PathCapType.hpp> #include <com/sun/star/rendering/PathCapType.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp> #include <com/sun/star/rendering/PathJoinType.hpp>
@@ -1180,14 +1179,16 @@ namespace cppcanvas
SAL_INFO("cppcanvas.emf", "EMF+\tfont\nEMF+\theader: 0x" << std::hex << (header >> 12) << " version: 0x" << (header & 0x1fff) << " size: " << std::dec << emSize << " unit: 0x" << std::hex << sizeUnit << std::dec); SAL_INFO("cppcanvas.emf", "EMF+\tfont\nEMF+\theader: 0x" << std::hex << (header >> 12) << " version: 0x" << (header & 0x1fff) << " size: " << std::dec << emSize << " unit: 0x" << std::hex << sizeUnit << std::dec);
SAL_INFO("cppcanvas.emf", "EMF+\tflags: 0x" << std::hex << fontFlags << " reserved: 0x" << reserved << " length: 0x" << std::hex << length << std::dec); SAL_INFO("cppcanvas.emf", "EMF+\tflags: 0x" << std::hex << fontFlags << " reserved: 0x" << reserved << " length: 0x" << std::hex << length << std::dec);
if( length > 0 && length < 0x4000 ) { if (length > 0 && length < 0x4000)
sal_Unicode *chars = static_cast<sal_Unicode *>(alloca( sizeof( sal_Unicode ) * length )); {
rtl_uString *pStr = rtl_uString_alloc(length);
sal_Unicode *chars = pStr->buffer;
for( sal_uInt32 i = 0; i < length; i++ ) for (sal_uInt32 i = 0; i < length; ++i)
s.ReadUtf16(chars[i]); s.ReadUtf16(chars[i]);
family = OUString( chars, length ); family = OUString(pStr, SAL_NO_ACQUIRE);
SAL_INFO("cppcanvas.emf", "EMF+\tfamily: " << OUStringToOString( family, RTL_TEXTENCODING_UTF8).getStr()); // TODO: can we just use family? SAL_INFO("cppcanvas.emf", "EMF+\tfamily: " << family);
} }
} }
}; };

View File

@@ -362,33 +362,6 @@ static const short yycheck[] = { 11,
It was written by Richard Stallman by simplifying the hairy parser It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */ used when %semantic_parser is specified. */
#ifndef YYSTACK_USE_ALLOCA
#ifdef alloca
#define YYSTACK_USE_ALLOCA
#else /* alloca not defined */
#ifdef __GNUC__
#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || (defined (__sun) && defined (__i386))
#define YYSTACK_USE_ALLOCA
#include <sal/alloca.h>
#else /* not sparc */
#if defined(_AIX)
#pragma alloca
#define YYSTACK_USE_ALLOCA
#endif /* not _AIX */
#endif /* not sparc */
#endif /* not GNU C */
#endif /* alloca not defined */
#endif /* YYSTACK_USE_ALLOCA not defined */
#ifdef YYSTACK_USE_ALLOCA
#define YYSTACK_ALLOC alloca
#else
#define YYSTACK_ALLOC malloc
#endif
/* Note: there must be only one dollar sign in this file. /* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action It is replaced by the list of actions, each action
as one case of the switch. */ as one case of the switch. */
@@ -612,17 +585,15 @@ yynewstate:
yystacksize *= 2; yystacksize *= 2;
if (yystacksize > YYMAXDEPTH) if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH; yystacksize = YYMAXDEPTH;
#ifndef YYSTACK_USE_ALLOCA
yyfree_stacks = 1; yyfree_stacks = 1;
#endif yyss = static_cast<short *>(malloc (yystacksize * sizeof (*yyssp)));
yyss = static_cast<short *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)));
memcpy (yyss, yyss1, memcpy (yyss, yyss1,
size * (unsigned int) sizeof (*yyssp)); size * (unsigned int) sizeof (*yyssp));
yyvs = static_cast<YYSTYPE *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp))); yyvs = static_cast<YYSTYPE *>(malloc (yystacksize * sizeof (*yyvsp)));
memcpy (yyvs, yyvs1, memcpy (yyvs, yyvs1,
size * (unsigned int) sizeof (*yyvsp)); size * (unsigned int) sizeof (*yyvsp));
#ifdef YYLSP_NEEDED #ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); yyls = (YYLTYPE *) malloc (yystacksize * sizeof (*yylsp));
memcpy ((char *)yyls, (char *)yyls1, memcpy ((char *)yyls, (char *)yyls1,
size * (unsigned int) sizeof (*yylsp)); size * (unsigned int) sizeof (*yylsp));
#endif #endif