summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-01-02 21:10:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-01-02 21:22:18 +0000
commit48954af3bc0957da9bf0d5ef9eb07c9079285932 (patch)
treee4cef05b422ca2f6e315bbff49c0caded743101f
parent35bc9668567a8c61763715f0854a42324dc5a4f4 (diff)
coverity#708661 Uninitialized scalar field
Change-Id: I1e87e7f6d135f9e4a0b4efbb4ce7e6e08663f675
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.cxx39
1 files changed, 16 insertions, 23 deletions
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index 14b32dc6bb16..e929f6be0615 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -63,41 +63,35 @@
#define DBG_TESTTRANS( _def_drawable )
#endif // (OSL_DEBUG_LEVEL > 1) && defined SALGDI2_TESTTRANS
-#define STATIC_POINTS 64
-
/* From <X11/Intrinsic.h> */
typedef unsigned long Pixel;
class SalPolyLine
{
- XPoint Points_[STATIC_POINTS];
- XPoint *pFirst_;
+ std::vector<XPoint> Points_;
public:
SalPolyLine(sal_uLong nPoints, const SalPoint *p)
- : pFirst_(nPoints+1 > STATIC_POINTS ? new XPoint[nPoints+1] : Points_)
+ : Points_(nPoints+1)
{
- for( sal_uLong i = 0; i < nPoints; i++ )
+ for (sal_uLong i = 0; i < nPoints; ++i)
{
- pFirst_[i].x = (short)p[i].mnX;
- pFirst_[i].y = (short)p[i].mnY;
+ Points_[i].x = (short)p[i].mnX;
+ Points_[i].y = (short)p[i].mnY;
}
- pFirst_[nPoints] = pFirst_[0]; // close polyline
+ Points_[nPoints] = Points_[0]; // close polyline
}
- ~SalPolyLine()
+ const XPoint &operator[](sal_uLong n) const
{
- if( pFirst_ != Points_ )
- delete [] pFirst_;
+ return Points_[n];
}
- XPoint &operator [] ( sal_uLong n ) const
+ XPoint &operator[](sal_uLong n)
{
- return pFirst_[n];
+ return Points_[n];
}
};
-#undef STATIC_POINTS
-
namespace
{
void setForeBack(XGCValues& rValues, const SalColormap& rColMap, const SalBitmap& rSalBitmap)
@@ -480,11 +474,10 @@ GC X11SalGraphicsImpl::SelectPen()
return mpPenGC;
}
-void X11SalGraphicsImpl::DrawLines( sal_uLong nPoints,
- const SalPolyLine &rPoints,
- GC pGC,
- bool bClose
- )
+void X11SalGraphicsImpl::DrawLines(sal_uLong nPoints,
+ const SalPolyLine &rPoints,
+ GC pGC,
+ bool bClose)
{
// calculate how many lines XWindow can draw in one go
sal_uLong nMaxLines = (mrParent.GetDisplay()->GetMaxRequestSize() - sizeof(xPolyPointReq))
@@ -497,7 +490,7 @@ void X11SalGraphicsImpl::DrawLines( sal_uLong nPoints,
XDrawLines( mrParent.GetXDisplay(),
mrParent.GetDrawable(),
pGC,
- &rPoints[n],
+ const_cast<XPoint*>(&rPoints[n]),
nMaxLines,
CoordModeOrigin );
@@ -505,7 +498,7 @@ void X11SalGraphicsImpl::DrawLines( sal_uLong nPoints,
XDrawLines( mrParent.GetXDisplay(),
mrParent.GetDrawable(),
pGC,
- &rPoints[n],
+ const_cast<XPoint*>(&rPoints[n]),
nPoints - n,
CoordModeOrigin );
if( bClose )