[omniORB] Non-NULL terminated strings

David movling at gmail.com
Tue May 27 11:28:58 BST 2008


Hi folks,

I'm going to re-open this thread for a moment. So, currently I have this IDL
representation:

typedef sequence<octet> StringData;
struct MyStruct {
  StringData s;
};

Then I define a function to convert a char * to a StringData:

StringData *convert( char *char_p, int len ) {
  CORBA::Octet *chars = new CORBA::Octet[len];
  for ( int i = 0; i < len; i++ ) {
      chars[i] = char_p[i];
  }
  return new StringData(len, len, chars, false);
}

It is then used like this:

void foo( char *p, int len ) {
  struct MyStruct myStruct;
  myStruct.s = StringData_var( convert( p, len ) );
  // ... do stuff
}

Now my question is, is the memory I have allocated here with the new
StringData and new Octet freed when foo() returns? How much does the
StringData_var take care of -- i.e., does it free the Octets? Could someone
clarify the meaning of the fourth parameter to new StringData()? I have a
feeling that it might be relevant here.

Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080527/056ef918/attachment.htm


More information about the omniORB-list mailing list