[Insight-developers] itk::Array operator= missing?
Bill Lorensen
wlorens1 at nycap.rr.com
Fri May 28 12:51:13 EDT 2004
I suggest that we do not make any changes that might confuse the Borland
compiler until the current Borland errors are fixed,
Bill
At 11:59 AM 5/28/2004, Julien Jomier wrote:
>Hi Lydia,
>
>You are perfectly right.
>As fas as I remember, Borland compiler was unhappy with the overloading of
>the operator = .
>I just tried to overload the operator = but it doesn't seem to work, i.e it
>never runs the overloaded function in itkArray. One more thing I don't
>understand is why the copy operator is not calling the default constructor
>in itkArray? Is it using another constructor that we need to override?
>
>Do you think we can fix the problem by inverting the behavior of
>m_LetArrayManageMemory and setting it to false by default instead of true?
>
>Let me know if I can do anything to help with this,
>
>Julien
>
> > -----Original Message-----
> > From: insight-developers-bounces at itk.org
> > [mailto:insight-developers-bounces at itk.org] On Behalf Of Lydia Ng
> > Sent: Friday, May 28, 2004 1:17 AM
> > To: insight-developers at itk.org
> > Subject: [Insight-developers] itk::Array operator= missing?
> >
> >
> >
> > 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
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers at itk.org
> > http://www.itk.org/mailman/listinfo/insight-developers
> >
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers at itk.org
>http://www.itk.org/mailman/listinfo/insight-developers
More information about the Insight-developers
mailing list