[omniORB] How is this situation handled - delete non-heap data ?

Ali Reza A.Reza at zensar.com
Fri Nov 14 17:37:21 GMT 2003


I have a String_var constructed using String_var(char *). As I understand:
{1} char * (see code below) is allocated as local memory. 
{2} String_var assumes that the data its pointing too is always on the heap.
{3} A String_var constructed using char * (mind u not const char *) assumes ownership of the char * used to construct it.

   char * str = "Blank..."; // not a heap allocation
     {
       CORBA::String_var temp1(str);
       cout << temp1.in();
     }

When the String_var temp1 goes out of scope its destructor calls a delete on str - I assume. But a destructor on str should not be called because it is not allocated on the heap. So how is this situation being taken care of ?

Cheers



More information about the omniORB-list mailing list