I'm not too sure why I'm getting memory leaks...hopefully someone here is wiser than me, and can help me find it :P .
#include "Canvas.h"
CDrawer CCanvas::gCanvas(RGB(0,0,0), 1);
int const GREEN(20000),BLUE(50), RED(200), THICK(3);
CCanvas::CCanvas(void): _iSize(0), _cptPoints(0)
{
}
CCanvas::CCanvas(CCanvas const & tmpCanvas): _iSize(tmpCanvas._iSize)
{
if (_iSize > 0)
{
_cptPoints = new CPt [_iSize];
for (int i(0); i < _iSize; ++i)
{
_cptPoints[i]._iX = tmpCanvas._cptPoints[i]._iX;
_cptPoints[i]._iY = tmpCanvas._cptPoints[i]._iY;
_cptPoints[i]._COLOR = GREEN;
}
}
}
CCanvas CCanvas::operator =(const CCanvas & RHS)
{
if (RHS._iSize > 0)
{
_iSize = RHS._iSize;
_cptPoints = new CPt [RHS._iSize];
for (int i(0); i < _iSize; i++)
{
_cptPoints[i]._iX = RHS._cptPoints[i]._iX;
_cptPoints[i]._iY = RHS._cptPoints[i]._iY;
_cptPoints[i]._COLOR = RED;
}
}
return *this;
}
CCanvas & CCanvas::Show(void)
{
if (_iSize > 1)
{
gCanvas.Clear();
for (int i(0); i < _iSize - 1; ++i)
{
for (int ii(i + 1); ii < _iSize; ++ii)
if (i != ii)
ShowPts(gCanvas, _cptPoints[i], _cptPoints[ii]);
}
gCanvas.Render();
}
return *this;
}
CCanvas::~CCanvas(void)
{
Clean();
}
CCanvas & CCanvas::AddLines(int iX, int iY, COLORREF tmpCol)
{
CPt * Tmp = new CPt [_iSize + 1];
for (int i(0); i < _iSize; ++i)
{
Tmp[i]._iX = _cptPoints[i]._iX;
Tmp[i]._iY = _cptPoints[i]._iY;
Tmp[i]._COLOR = _cptPoints[i]._COLOR;
}
Clean();
_cptPoints = new CPt [++_iSize];
_cptPoints = Tmp;
Tmp = 0;
_cptPoints[_iSize-1]._iX = iX;
_cptPoints[_iSize-1]._iY = iY;
_cptPoints[_iSize-1]._COLOR = tmpCol;
Show();
return *this;
}
void CCanvas::Clean(void)
{
delete [] _cptPoints;
_cptPoints = 0;
}
this is the class where it's occurring. If anyone needs the other classes/files just ask. Thanks!