Name
XtNewString — copy an instance of a string.
Synopsis
String XtNewString(string)
String string;
Arguments
stringSpecifies a NULL-terminated string.
Description
XtNewString is used to copy an instance of a string. It returns a pointer to the allocated storage. If there is insufficient memory to allocate the new block, XtNewString calls XtErrorMsg. For example, XtNew(XtCallbackList) allocates storage for one callback list structure. XtNewString is a macro that allocates storage for a string, copies the string into the new storage, and returns the pointer. For example, a string can be copied into new storage using the following:
static String buf[] = "How do you do?";
String p;
p = XtNewString(buf);
After this sequence, p points to a separate string that contains "How do you do?" Then buf can be changed without affecting p.
XtNewString is a convenience macro that calls XtMalloc with the following arguments specified:
(strcpy(XtMalloc((unsigned) strlen(str) + 1), str))