1
0
forked from 0ad/0ad

Better fix of Grid memory leak, refs #1842

This was SVN commit r13869.
This commit is contained in:
historic_bruno 2013-09-18 01:21:36 +00:00
parent e10c4ebaae
commit bfe0b79b91

View File

@ -48,16 +48,8 @@ public:
Grid(const Grid& g)
{
m_W = g.m_W;
m_H = g.m_H;
m_DirtyID = g.m_DirtyID;
if (g.m_Data)
{
m_Data = new T[m_W * m_H];
memcpy(m_Data, g.m_Data, m_W*m_H*sizeof(T));
}
else
m_Data = NULL;
m_Data = NULL;
*this = g;
}
Grid& operator=(const Grid& g)
@ -67,12 +59,11 @@ public:
m_W = g.m_W;
m_H = g.m_H;
m_DirtyID = g.m_DirtyID;
delete[] m_Data;
if (g.m_Data)
{
T* ptr = new T[m_W * m_H];
memcpy(ptr, g.m_Data, m_W*m_H*sizeof(T));
delete[] m_Data;
m_Data = ptr;
m_Data = new T[m_W * m_H];
memcpy(m_Data, g.m_Data, m_W*m_H*sizeof(T));
}
else
m_Data = NULL;