14.18 Strings

The mapping of these functions to C++ is as follows:

// C++
namespace CORBA {
static char * string_alloc(ULong len);
static char * string_dup (const char *);
static void string_free(char *);
...
} 

Note:

A static array of char in C++ decays to a char*. Therefore, care must be taken when assigning a static array to a String_var, because the String_var assumes that the pointer points to data allocated via string_alloc, and thus eventually attempts to free it using string_free.

This behavior has changed in ANSI/ISO C++, where string literals are const char*, not char*. However, since most C++ compilers do not yet implement this change, portable programs must heed the advice given here.

The following sections describe the functions that manage memory allocated to strings.