Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

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

Media Vault

Software Library

Restoration Projects

Artifacts Sought

 

NAME

XtNewString − copy an instance of a string. 

SYNOPSIS

String XtNewString(string)
    String string;

Inputs

stringSpecifies a NULL-terminated string. 

Returns

A copy of string in allocated memory. 

DESCRIPTION

XtNewString() allocates enough memory to hold a copy of the specified string and copies the string into that memory.  If there is insufficient 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. 

BACKGROUND

XtNewString() is defined as the following macro: #define XtNewString(str) \ #define XtNewString(str) \
    ((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1),
    str)) : NULL)

SEE ALSO

XtMallocUNIX SYSTEM V/68, XtFreeUNIX SYSTEM V/68, XtNewUNIX SYSTEM V/68. 

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