[Insight-developers] itk::Array operator= missing?
Lydia Ng
lng at insightful.com
Fri May 28 01:16:46 EDT 2004
I finally worked out the cause of the memory leak in the
itkShapePriorMAPCostFunctionTest. I believe is due to the
Array::m_LetArrayManageMemory not being set properly.
This is illustrated in the following code:
------------------------------
#include "itkArray.h"
int main()
{
typedef itk::Array<float> ArrayType;
//
// Create an itk::Array which manages its own memory
//
ArrayType myOwnBoss;
myOwnBoss.SetSize( 5 );
myOwnBoss.Fill( 2.0 );
//
// Create an itk::Array which does not manage its own memory
//
float buffer[7];
ArrayType notMyOwnBoss;
notMyOwnBoss.SetSize( 7 );
notMyOwnBoss.SetData( buffer, false );
notMyOwnBoss.Fill( 4.0 );
//
// Copy an itk::Array which manages its own
//
ArrayType test1 = myOwnBoss;
//
// Copy an itk::Array which does not manage its own memory
// After copying test2.m_LetArrayManageMemory is set to
// zero even though it has created its own memory - thus
// causing a memory leak.
//
ArrayType test2 = notMyOwnBoss;
return 0;
}
----------------------------
>From the cvs log of itkArray.h it looks like operator= for itk::Array was
added then deleted due to issues with bcc - does anyone know why?
- Lydia
More information about the Insight-developers
mailing list