Commit 159a4aea authored by kulvait's avatar kulvait

Niceness

Improvement of construction and destruction of some objects
parent 6cfa035f
......@@ -59,7 +59,14 @@ namespace io {
/**Destructor of BufferedFrame2D.
*
*/
~BufferedFrame2D() { delete[] slice; } // destructor
~BufferedFrame2D()
{
if(slice != nullptr)
{
delete[] slice;
}
slice = nullptr;
} // destructor
/**Copy assignment
*
......@@ -70,7 +77,10 @@ namespace io {
{
this->sizex = b.sizex;
this->sizey = b.sizey;
delete[] this->slice;
if(this->slice != nullptr)
{
delete[] this->slice;
}
this->slice = nullptr;
this->slice = new T[sizex * sizey];
memcpy(this->slice, b.slice, sizex * sizey * sizeof(T));
......@@ -91,7 +101,11 @@ namespace io {
{
if(&other != this)
{
delete[] this->slice;
if(this.slice != nullptr)
{
delete[] this->slice;
}
this->slice = nullptr;
this->slice = other.slice;
this->sizex = other.sizex;
this->sizey = other.sizey;
......
......@@ -60,9 +60,9 @@ namespace io {
{
this->denFile = denFile;
DenFileInfo pi = DenFileInfo(this->denFile);
this->sizey = pi.getNumRows();
this->sizex = pi.getNumCols();
this->sizez = pi.getNumSlices();
this->sizey = pi.dimx();
this->sizex = pi.dimy();
this->sizez = pi.dimz();
this->dataType = pi.getDataType();
this->elementByteSize = pi.elementByteSize();
this->buffer = new uint8_t[elementByteSize * sizex * sizey];
......@@ -81,10 +81,12 @@ namespace io {
{
delete[] buffer;
}
buffer = nullptr;
if(buffer_copy != nullptr)
{
delete[] buffer_copy;
}
buffer_copy = nullptr;
}
/**Copy constructor of DenFrame2DReader from another element.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment