[omniORB] Reference passing

Jacek Nowak jnowak@ernie.icslab.agh.edu.pl
Thu Aug 8 11:23:00 2002


I have the following problem:

I pass a _ptr reference to an object as an 'in' parameter of a function
and try keep a copy of it in a _var. Something like this:

void BarrierSrv_i::registerInBarrierServer( OrbiMan_ptr newManager){

  orbiMan_var = newManager_ptr;
  //orbiMan_var->_duplicate( orbiMan_var );

}

If I don't call _duplicate explicitly the reference gets deleted when
leaving the function, and the next attemp to use the _var reference causes
segmentation fault.

void BarrierSrv_i::test( ){
  orbiMan_var->ping(); // <- Segmentation fault
}

Is this correct behavior? I mean, do I have to call _duplicate explicitly?
I always thought _duplicate is called when the _var takes over ownership
from the _ptr.

Thanks,
Jacek