Hi!

I have an PalmOS C++ application with code like the
following:

//-------------------------------------------------------------

void TPrinterUtil::ReadConfiguration()
{
   TPrinterData& Data = * new TPrinterData(*dbName);

   // do something with Data

   delete &Data;

}

//-------------------------------------------------------------

I know that these two lines seem somewhat strange, but
the fact is,
they compile and run and, apparently, do their work as
they should.
However, one of my coworkers pointed to me it was
easier, and safer,
to write that code like this:

//-------------------------------------------------------------

void TPrinterUtil::ReadConfiguration()
{
   TPrinterData Data(*dbName);

   // do something with Data

   // Data need not be explicitly destroyed
}

//-------------------------------------------------------------

At first, I didn't see what could be the difference,
but he
(my coworker) told me my original code might not be
destroying
the memory block pointed to by Data, but something
else, like
system memory or unallocated space. Obviously, that
freaked me
out completely.

I need your opinion on this. Does this code do what my
coworker
says? If it does, I'm afraid I will need to rewrite
most of the
code in my application, and that scares me a lot!

 - Heriberto Delgado
   ([EMAIL PROTECTED],
    [EMAIL PROTECTED])





-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to