13.1.2 Strings

A string in OMG IDL is mapped to char * in C++. Both bounded and unbounded strings are mapped to char *. CORBA strings in C++ are NULL-terminated and can be used wherever a char * type is used.

If a string is contained within another user-defined type, such as a struct, it is mapped to a CORBA::String_var type. This ensures that each member in the struct manages its own memory.

Strings must be allocated and deallocated using the following member functions in the CORBA class:

  • string_alloc
  • string_dup
  • string_free

Note:

The string_alloc function allocates len+1 characters so that the resulting string has enough space to hold a trailing NULL character.