[omniORB] Who cleans up CORBA::string_dup'd memory?

Brecht Vermeulen brecht.vermeulen@rug.ac.be
Mon, 22 Oct 2001 18:00:23 +0200


Hi Mark,

string_dup does a deep copy, so indeed you have a copy of the string and
you have to clean up the memory !

of course if you assign it to a string_var, the _var will do it for you
:

CORBA::String_var test = CORBA::string_dup("");

this will clean up the memory when going out of scope.

For arguments in a function, the caller has to take over the management
for inout, out and return arguments.

regards,
Brecht

Mark Johnson wrote:
> 
> ENV: omniORB3.0, Solaris 2.8, CC
> 
> When using a CORBA::string_dup do you ever have to clean up that memory?
> 
> I just had a really bizarre situation where an application that has been
> running great for weeks all of a sudden started core dumping when displaying
> string_dup'd variables. I even stopped and restarted the application,
> restarted omniNames,  and even did a make clean and a rebuild it was still
> core dumping. Out of desparation I rebooted the machine and the problem
> seemed to go away...
> 
> ps: Is doing a CORBA::string_dup( "" ) safe?
> 
> For example:
>   void InitObject( MyStruct & obj )
>   {
>       obj.name = CORBA::string_dup( "" );
>   }