[omniORB] Changing lenght of CORBA::String_var type and setting new value.

Jason Etheridge jason at etheridge.org
Tue Oct 9 20:46:01 BST 2007


> I want to change lenght of CORB::String_var data variable in a loop and
> set new const string to my data variable.
...
> Server code:
> data = ( char*) "A";

Firstly, you should never initialise a CORBA::String_var (assuming
that's the type of 'data') to a non-const string. In other words, this
should be:

data = (const char *)"A";

> void stringTestServer_i::setSize(CORBA::Short& size)
> {
>  const char *str ="";
>  std::string s ="";
>
>  for(int i=0;i<size;i++)
>  {
>   s+="a";
>  }
>  str = s.c_str();
>  cout<<"Str="<<str<<endl;  str varaible changes as loop
>
>  data = CORBA::string_dup(str); --> Here is the problem data always prints A
>  cout<<"Data="<<*data<<endl;
> }

There's nothing obviously wrong with what you're doing. If you're
still having trouble, I'd suggest pasting the entire source file for
your implementation; it's possible there's something else wrong that's
in the missing code.

Cheers,
Jason.

-- 
Jason Etheridge                                     mailto:jason at etheridge.org



More information about the omniORB-list mailing list