Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

[Resolved] Possible leak in RawVolume::resize()
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=15&t=337
Page 1 of 1

Author:  realazthat [ Mon Feb 27, 2012 1:35 am ]
Post subject:  [Resolved] Possible leak in RawVolume::resize()

Code:
                //Create the data
                m_pData = new VoxelType[this->getWidth() * this->getHeight()* this->getDepth()];


m_pData is not being deleted before being pointed to a new array.

Author:  David Williams [ Mon Feb 27, 2012 10:19 am ]
Post subject:  Re: Possible leak in RawVolume::resize()

You are right... but actually there is a note above that function (which I would not expect you to have noticed) saying 'This function should probably be made internal...'. It's currently only being called from the constructor so no memory leak occurs, but do you have a scenario where you need to call it directly?

Of course it would be better to delete the data first, but I'm just wondering if I can't remove this function for some reason?

Author:  realazthat [ Mon Feb 27, 2012 2:47 pm ]
Post subject:  Re: Possible leak in RawVolume::resize()

David Williams wrote:
You are right... but actually there is a note above that function (which I would not expect you to have noticed) saying 'This function should probably be made internal...'. It's currently only being called from the constructor so no memory leak occurs, but do you have a scenario where you need to call it directly?

Of course it would be better to delete the data first, but I'm just wondering if I can't remove this function for some reason?


No, I don't use it, I just noticed it.

Author:  David Williams [ Tue Feb 28, 2012 10:00 am ]
Post subject:  Re: Possible leak in RawVolume::resize()

I've renamed 'resize' to 'initialise' and have also made it private. It basically holds code which is common to all the constructors. I think the new name makes the intention clearer.

Note that I've made this change locally, but it should get pushed through to Git master in the next few days.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/