summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-01-24 16:41:22 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-01-25 07:52:22 +0100
commitb6b5fd494f997be314d154df49c4017db99dda34 (patch)
treee6e56e6fff6d6e6312ea84e73d659f494a0898b0 /vcl
parent2a727074012aaaa782f41b0f4470c95f095e030e (diff)
Allocate ImplPointArray::mpArray as a true Point[]
...as the default Point ctor already zero-initializes its members, removing the need for the memset call (that causes -Werror=class-memaccess, "clearing an object of non-trivial type 'class Point'" with upcoming GCC 8). Also use unique_ptr. Change-Id: Idc139b97e18c0d48079a14755124be72da91fb37 Reviewed-on: https://gerrit.libreoffice.org/48522 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/impvect.cxx20
1 files changed, 5 insertions, 15 deletions
diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx
index b94886a841b1..5e7e8e31e4b6 100644
--- a/vcl/source/gdi/impvect.cxx
+++ b/vcl/source/gdi/impvect.cxx
@@ -18,6 +18,8 @@
*/
#include <stdlib.h>
+
+#include <o3tl/make_unique.hxx>
#include <vcl/bitmapaccess.hxx>
#include <tools/poly.hxx>
#include <vcl/gdimtf.hxx>
@@ -123,14 +125,13 @@ extern "C" int ImplColorSetCmpFnc( const void* p1, const void* p2 )
class ImplPointArray
{
- Point* mpArray;
+ std::unique_ptr<Point[]> mpArray;
sal_uLong mnSize;
sal_uLong mnRealSize;
public:
ImplPointArray();
- ~ImplPointArray();
void ImplSetSize( sal_uLong nSize );
sal_uLong ImplGetRealSize() const { return mnRealSize; }
@@ -143,19 +144,12 @@ public:
};
ImplPointArray::ImplPointArray() :
- mpArray ( nullptr ),
mnSize ( 0 ),
mnRealSize ( 0 )
{
}
-ImplPointArray::~ImplPointArray()
-{
- if( mpArray )
- rtl_freeMemory( mpArray );
-}
-
void ImplPointArray::ImplSetSize( sal_uLong nSize )
{
const sal_uLong nTotal = nSize * sizeof( Point );
@@ -163,11 +157,7 @@ void ImplPointArray::ImplSetSize( sal_uLong nSize )
mnSize = nSize;
mnRealSize = 0;
- if( mpArray )
- rtl_freeMemory( mpArray );
-
- mpArray = static_cast<Point*>(rtl_allocateMemory( nTotal ));
- memset( mpArray, 0, nTotal );
+ mpArray = o3tl::make_unique<Point[]>( nTotal );
}
inline Point& ImplPointArray::operator[]( sal_uLong nPos )
@@ -184,7 +174,7 @@ inline const Point& ImplPointArray::operator[]( sal_uLong nPos ) const
void ImplPointArray::ImplCreatePoly( tools::Polygon& rPoly ) const
{
- rPoly = tools::Polygon( sal::static_int_cast<sal_uInt16>(mnRealSize), mpArray );
+ rPoly = tools::Polygon( sal::static_int_cast<sal_uInt16>(mnRealSize), mpArray.get() );
}
class ImplVectMap