Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ New(3X) — DeltaWindows 1.3.3 Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

 

NAME

XtNew − allocate storage for one instance of a data type. 

SYNOPSIS

type ∗XtNew(type)

Inputs

typeSpecifies a  data type.  Note that this is not a variable. 

Returns

A pointer to sufficient allocated memory to store a variable of type type. 

DESCRIPTION

XtNew() 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 variable) 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(). 

EXAMPLE

XtNew() can be used as follows: typedef struct _node {
    int value;
    struct _node next; } Node;
 
Node ∗n = XtNew(Node);

BACKGROUND

XtNew() is simply the following macro: #define XtNew(type) ((type ∗) XtMalloc((unsigned) sizeof(type)))

SEE ALSO

XtMallocUNIX SYSTEM V/68, XtNewStringUNIX SYSTEM V/68. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026