[omniORB] Re: Sequences and Java Client

David Riddoch djr@uk.research.att.com
Fri, 12 Feb 1999 16:57:11 +0000 (GMT)


On Fri, 12 Feb 1999, Armen Yampolsky wrote:

> Is it sensible to hold the reference to the Echos' sequence? I am doing that
> by calling its copy constructor just prior to returning it (I am returning
> the copy, and holding the reference to the original)?

This sounds okay. You just have to remember that the sequence you return
from EchoList::getEchos() will be freed by the ORB (using delete), so it
MUST be heap allocated, and you must not hold onto that pointer.

I assume you're doing something like:

Echoseq*
EchoList_i::getEchos()
{
  Echoseq* seq = new Echoseq();

  ... initialise the sequence ...
  ... store <seq> somewhere ...

  return new Echoseq(*seq);
}

This will duplicate the references to the Echo objects appropriately.


David