a questiong about the return value type "CORBA_char *"



hi , 

  i am a new comer of this community.
i want to make some questions clear :)

 any help will be appreciated .


the following is an example copied from basicServer.c
shipped with ORBit-0.5.13.tar.gz

static
CORBA_char *
BasicServer__get_foo(PortableServer_Servant servant,
      CORBA_Environment *ev) {
  return CORBA_string_dup(constants_STRING_RETN);  
}


  CORBA_string_dup() will allocate a new memory block,
which will be freed by the system after the 
BasicServer__get_foo() returns, is that it?


if so how about the following procedure:

static
CORBA_char *
BasicServer__get_foo(PortableServer_Servant servant,
      CORBA_Environment *ev) {

  CORBA_char *retval;

  retval = CORBA_string_dup(constants_STRING_RETN);  
  /* do something interesting here */
  return retval;  
}

the only modification is i defined a temporary variable
"retval", i wonder whether this procedure is quite the 
same as the first one ? That is , whether the memory 
block pointed by the retval will be freed automatically
by the system after the BasicServer__get_foo() returns?

folke.
thanks in advance.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]