diff --git a/Modules/Core/Common/test/itkFactoryTestLib.cxx b/Modules/Core/Common/test/itkFactoryTestLib.cxx index e161e535852..eea9007cbbe 100644 --- a/Modules/Core/Common/test/itkFactoryTestLib.cxx +++ b/Modules/Core/Common/test/itkFactoryTestLib.cxx @@ -43,8 +43,6 @@ class TestImportImageContainer : public itk::ImportImageContainer; - // Methods from itkObject virtual ~TestImportImageContainer() { @@ -67,21 +65,9 @@ class TestImportImageContainer : public itk::ImportImageContainer(m_Allocator.allocate(size, 0)); - if (data) - { - new (data) Element[size]; - } + data = new Element[size]; } catch (...) - { - data = 0; - } - if (!data) { // We cannot construct an error string here because we may be out // of memory. Do not use the exception macro. @@ -91,7 +77,7 @@ class TestImportImageContainer : public itk::ImportImageContainerCapacity() << " bytes" << std::endl; - if (m_MemoryAllocatedByAllocator) + if (m_MemoryAllocatedByTestImportImageContainer) { - TElement * ptr = this->GetImportPointer(); - const TElement * const end = ptr + this->Capacity(); - for (TElement * base = ptr; base < end; ++base) - { - m_Allocator.destroy(base); - } - m_Allocator.deallocate(ptr, this->Capacity()); - + delete[] this->GetImportPointer(); this->SetImportPointer(0); this->SetCapacity(0); this->SetSize(0); @@ -130,8 +109,7 @@ class TestImportImageContainer : public itk::ImportImageContainer