XtNewString()XtNewString()NameXtNewString - copy an instance of a string.
Synopsis
String XtNewString(string)
String string;
Inputs
string Specifies a NULL-terminated string.
Returns
A copy of string in allocated memory.
DescriptionXtNewString() allocates enough memory to hold a copy of the specified
string and copies the string into that memory. If there is insuffi‐
cient memory to allocate the new block, XtNewString() prints an error
message and terminates the application by calling XtErrorMsg().
Usage
Memory allocated with XtNewString() must be deallocated with XtFree().
To simply allocate a specified amount of memory, use XtMalloc(). To
allocate enough memory for one instance of a specified type, use
XtNew().
Example
You might use XtNewString() in a situation like this:
String name = XtNewString(XtName(w));
XtName() returns a string that may not be modified. If you copy it,
however, you can do anything you like with it, as long as you remember
to free it when you are done with it.
BackgroundXtNewString() is defined as the following macro:
#define XtNewString(str) #define XtNewString(str) ((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1),
str)) : NULL)
See AlsoXtMalloc(1), XtFree(1), XtNew(1).
Xt - Memory Allocation XtNewString()