Fix -Wclass-memaccess warning

Replace C-style memset with C++ value-initialization/assignment (smarter and safer: see https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slcon3-avoid-bounds-errors)
This commit is contained in:
howetuft
2019-11-03 15:34:40 +01:00
committed by wmayer
parent 71dae0e639
commit 4b5ca31149
3 changed files with 23 additions and 24 deletions

View File

@@ -31,7 +31,7 @@ MeshCurvature<Real>::MeshCurvature (int iVQuantity,
// compute normal vectors
m_akNormal = WM4_NEW Vector3<Real>[m_iVQuantity];
memset(m_akNormal,0,m_iVQuantity*sizeof(Vector3<Real>));
std::fill_n(m_akNormal,m_iVQuantity,Vector3<Real>{0,0,0});
int i, iV0, iV1, iV2;
for (i = 0; i < m_iTQuantity; i++)
{
@@ -58,8 +58,8 @@ MeshCurvature<Real>::MeshCurvature (int iVQuantity,
Matrix3<Real>* akDNormal = WM4_NEW Matrix3<Real>[m_iVQuantity];
Matrix3<Real>* akWWTrn = WM4_NEW Matrix3<Real>[m_iVQuantity];
Matrix3<Real>* akDWTrn = WM4_NEW Matrix3<Real>[m_iVQuantity];
memset(akWWTrn,0,m_iVQuantity*sizeof(Matrix3<Real>));
memset(akDWTrn,0,m_iVQuantity*sizeof(Matrix3<Real>));
std::fill_n(akWWTrn,m_iVQuantity,Matrix3<Real>{0,0,0,0,0,0,0,0,0});
std::fill_n(akDWTrn,m_iVQuantity,Matrix3<Real>{0,0,0,0,0,0,0,0,0});
int iRow, iCol;
aiIndex = m_aiIndex;

View File

@@ -89,8 +89,8 @@ void MeshSmoother<Real>::Destroy ()
template <class Real>
void MeshSmoother<Real>::Update (Real fTime)
{
memset(m_akNormal,0,m_iVQuantity*sizeof(Vector3<Real>));
memset(m_akMean,0,m_iVQuantity*sizeof(Vector3<Real>));
std::fill_n(m_akNormal,m_iVQuantity,Vector3<Real>{0,0,0});
std::fill_n(m_akMean,m_iVQuantity,Vector3<Real>{0,0,0});
const int* piIndex = m_aiIndex;
int i;

View File

@@ -64,24 +64,24 @@ static int const Skip = -2; //edge that would otherwise close a path
#define NEAR_ZERO(val) (((val) > -TOLERANCE) && ((val) < TOLERANCE))
struct TEdge {
IntPoint Bot;
IntPoint Curr;
IntPoint Top;
IntPoint Delta;
double Dx;
PolyType PolyTyp;
EdgeSide Side;
int WindDelta; //1 or -1 depending on winding direction
int WindCnt;
int WindCnt2; //winding count of the opposite polytype
int OutIdx;
TEdge *Next;
TEdge *Prev;
TEdge *NextInLML;
TEdge *NextInAEL;
TEdge *PrevInAEL;
TEdge *NextInSEL;
TEdge *PrevInSEL;
IntPoint Bot{0,0};
IntPoint Curr{0,0};
IntPoint Top{0,0};
IntPoint Delta{0,0};
double Dx = 0.0;
PolyType PolyTyp = ptSubject;
EdgeSide Side = esLeft;
int WindDelta = 0; //1 or -1 depending on winding direction
int WindCnt = 0;
int WindCnt2 = 0; //winding count of the opposite polytype
int OutIdx = 0;
TEdge *Next = nullptr;
TEdge *Prev = nullptr;
TEdge *NextInLML = nullptr;
TEdge *NextInAEL = nullptr;
TEdge *PrevInAEL = nullptr;
TEdge *NextInSEL = nullptr;
TEdge *PrevInSEL = nullptr;
};
struct IntersectNode {
@@ -715,7 +715,6 @@ void DisposeOutPts(OutPt*& pp)
inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt)
{
std::memset(e, 0, sizeof(TEdge));
e->Next = eNext;
e->Prev = ePrev;
e->Curr = Pt;