[Libreoffice-commits] core.git: 2 commits - sw/source vcl/source
Stephan Bergmann
sbergman at redhat.com
Thu Jan 25 06:52:31 UTC 2018
sw/source/core/crsr/findattr.cxx | 8 ++++++--
vcl/source/gdi/impvect.cxx | 20 +++++---------------
2 files changed, 11 insertions(+), 17 deletions(-)
New commits:
commit b6b5fd494f997be314d154df49c4017db99dda34
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jan 24 16:41:22 2018 +0100
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 at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
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
commit 2a727074012aaaa782f41b0f4470c95f095e030e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jan 24 16:31:31 2018 +0100
Use std::fill instead of memset
...to avoid GCC 8 -Werror=class-memaccess ("clearing an object of non-trivial
type ‘struct SwSrchChrAttr’"). Similar to
<https://gerrit.libreoffice.org/#/c/48488/> "Allocate ImpXPolygon::pPointAry as
a true Point[]", std::fill appears to produce adequate code here with recent
compilers.
Change-Id: I3ee0bc15e852b80e0429c8e0a4bc48424af9c5a3
Reviewed-on: https://gerrit.libreoffice.org/48518
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 3eed69cbc92a..d2d35f229f08 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -43,6 +43,8 @@
#include <pamtyp.hxx>
#include <swundo.hxx>
#include <boost/optional.hpp>
+
+#include <algorithm>
#include <memory>
using namespace ::com::sun::star;
@@ -183,6 +185,8 @@ struct SwSrchChrAttr
sal_Int32 nStt;
sal_Int32 nEnd;
+ SwSrchChrAttr(): nWhich(0), nStt(0), nEnd(0) {}
+
SwSrchChrAttr( const SfxPoolItem& rItem,
sal_Int32 nStart, sal_Int32 nAnyEnd )
: nWhich( rItem.Which() ), nStt( nStart ), nEnd( nAnyEnd )
@@ -253,8 +257,8 @@ SwAttrCheckArr::~SwAttrCheckArr()
void SwAttrCheckArr::SetNewSet( const SwTextNode& rTextNd, const SwPaM& rPam )
{
- memset( pFndArr, 0, nArrLen * sizeof(SwSrchChrAttr) );
- memset( pStackArr, 0, nArrLen * sizeof(SwSrchChrAttr) );
+ std::fill(pFndArr, pFndArr + nArrLen, SwSrchChrAttr());
+ std::fill(pStackArr, pStackArr + nArrLen, SwSrchChrAttr());
nFound = 0;
nStackCnt = 0;
More information about the Libreoffice-commits
mailing list