Fix the -Wclass-memaccess compiler warning in the pathfinders Grid.h, refs #5294.

Differential Revision: https://code.wildfiregames.com/D2099
Reviewed By: historic_bruno, wraitii
This was SVN commit r22511.
This commit is contained in:
elexis
2019-07-19 12:52:10 +00:00
parent e6f960bca6
commit 3a839517ce
+4 -6
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games. /* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@@ -190,8 +190,7 @@ class SparseGrid
size_t b = (j >> BucketBits) * m_BW + (i >> BucketBits); size_t b = (j >> BucketBits) * m_BW + (i >> BucketBits);
if (!m_Data[b]) if (!m_Data[b])
{ {
m_Data[b] = new T[BucketSize*BucketSize]; m_Data[b] = new T[BucketSize*BucketSize]();
memset(m_Data[b], 0, BucketSize*BucketSize*sizeof(T));
} }
return m_Data[b]; return m_Data[b];
} }
@@ -204,8 +203,7 @@ public:
m_BW = (u16)((m_W + BucketSize-1) >> BucketBits); m_BW = (u16)((m_W + BucketSize-1) >> BucketBits);
m_BH = (u16)((m_H + BucketSize-1) >> BucketBits); m_BH = (u16)((m_H + BucketSize-1) >> BucketBits);
m_Data = new T*[m_BW*m_BH]; m_Data = new T*[m_BW*m_BH]();
memset(m_Data, 0, m_BW*m_BH*sizeof(T*));
} }
~SparseGrid() ~SparseGrid()
@@ -219,7 +217,7 @@ public:
for (size_t i = 0; i < (size_t)(m_BW*m_BH); ++i) for (size_t i = 0; i < (size_t)(m_BW*m_BH); ++i)
delete[] m_Data[i]; delete[] m_Data[i];
memset(m_Data, 0, m_BW*m_BH*sizeof(T*)); m_Data = new T*[m_BW*m_BH]();
} }
void set(int i, int j, const T& value) void set(int i, int j, const T& value)