XtNew()XtNew()NameXtNew - allocate storage for one instance of a data type.
Synopsis
type *XtNew(type)Inputs
type Specifies a data type. Note that this is not a variable.
Returns
A pointer to sufficient allocated memory to store a variable of type
type.
DescriptionXtNew() is a macro used to allocate storage for one instance of the
data type type. It is called with the datatype (a type, not a vari‐
able) and returns a pointer to enough allocated memory to hold that
type. The return value is correctly cast to type *.
If there is insufficient memory, XtNew() calls XtErrorMsg() to display
an error message and terminate the application.
Usage
Memory allocated with XtNew() must be deallocated with XtFree().
To allocate memory and copy an a string, use XtNewString().
ExampleXtNew() can be used as follows:
typedef struct _node {
int value;
struct _node next;
} Node;
Node *n = XtNew(Node);
BackgroundXtNew() is simply the following macro:
#define XtNew(type) ((type *) XtMalloc((unsigned) sizeof(type)))
See AlsoXtMalloc(1), XtNewString(1).
Xt - Memory Allocation XtNew()