![]() |
Overview Allocates storage for a string. Original class CORBA
Intended Usage
This method is intended to be used by client and server applications to dynamically allocate storage for data of type CORBA::String. The returned storage should subsequently be freed using CORBA::wstring_free(). Strings can also be copied using CORBA::wstring_dup().
WStrings to be passed on remote method invocations or whose ownership is to be transferred from one library to another should be allocated using this method (or CORBA::wstring_dup()) rather than the C++ new[ ] operator. This insures that string memory is deleted using the same C++ run time that originally allocated it.
IDL Syntax
static wchar_t* wstring_alloc(CORBA::ULong len);
Input parameters
- len
- The size of the string whose storage is to be allocated.
Return values
- wchar_t*
- The uninitialized wstring storage. This storage should later be freed using CORBA::wstring_free(). NULL is returned if the storage cannot be allocated.
Example
/* The following is a C++ example */ #include "corba.h" ... /* Allocate 8 wchars for string buf */ wchar_t* buf = CORBA::wstring_alloc(8); /* String copy buf */ wchar_t* buf_dup = CORBA::wstring_dup(buf); /* Use buf and buf_dup */ ... /* Free buf and buf_dup */ CORBA::wstring_free(buf); CORBA::wstring_free(buf_dup);