[omniORB] T_var in an STL Container

Stefan Seefeld seefelds@MAGELLAN.UMontreal.CA
Thu, 09 Mar 2000 13:54:27 -0500


Ken Feuerman wrote:

> Thanks!  But now your comment about _duplicate() worries me.  I think if I
> have a function
> 
> T_ptr GetATObj();
> 
> then the following code should be correct without leaking T resources:
> 
> {
>     T_var myTObj = GetATobj();
> } // myTObj leaves scope, releasing the T proxy
> 
> Are you saying that this should be
> 
> {
>     T_var myTObj = T::_duplicate(GetATobj());
> }
> 
> instead?

no, because the duplicate is done before the method returned, either by you
if you implemented that method (i.e. it's a local call) or by the ORB if
it returns from an up-call (i.e. the method is part of an auto-generated proxy). 
All is fine.

However, if the pointer is from an 'in' parameter of a method, you do need
to duplicate yourself.

void ServerImpl::registerObject(const char *name, Object_ptr object)
{
  table[name] = Object::_duplicate(object);
}

Regards,	Stefan
_______________________________________________________              
              
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca

_______________________________________________________

      ...ich hab' noch einen Koffer in Berlin...