XtNew() XtNew()
Name
XtNew - 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.
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 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().
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 AlsoXtMalloc(1), XtNewString(1).
Xt - Memory Allocation XtNew()
Check Out this Related Man Page
XtMalloc(3) XT FUNCTIONS XtMalloc(3)NAME
XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString - memory management functions
SYNTAX
char *XtMalloc(Cardinal size);
char *XtCalloc(Cardinal num, Cardinal size);
char *XtRealloc(char *ptr, Cardinal num);
void XtFree(char *ptr);
type *XtNew(type);
String XtNewString(String string);
ARGUMENTS
num Specifies the number of bytes or array elements.
ptr Specifies a pointer to the old storage or to the block of storage that is to be freed.
size Specifies the size of an array element (in bytes) or the number of bytes desired.
string Specifies a previously declared string.
type Specifies a previously declared data type.
DESCRIPTION
The XtMalloc functions returns a pointer to a block of storage of at least the specified size bytes. If there is insufficient memory to
allocate the new block, XtMalloc calls XtErrorMsg.
The XtCalloc function allocates space for the specified number of array elements of the specified size and initializes the space to zero.
If there is insufficient memory to allocate the new block, XtCalloc calls XtErrorMsg.
The XtRealloc function changes the size of a block of storage (possibly moving it). Then, it copies the old contents (or as much as will
fit) into the new block and frees the old block. If there is insufficient memory to allocate the new block, XtRealloc calls XtErrorMsg.
If ptr is NULL, XtRealloc allocates the new storage without copying the old contents; that is, it simply calls XtMalloc.
The XtFree function returns storage and allows it to be reused. If ptr is NULL, XtFree returns immediately.
XtNew returns a pointer to the allocated storage. If there is insufficient memory to allocate the new block, XtNew calls XtErrorMsg.
XtNew is a convenience macro that calls XtMalloc with the following arguments specified:
((type *) XtMalloc((unsigned) sizeof(type))
XtNewString returns a pointer to the allocated storage. If there is insufficient memory to allocate the new block, XtNewString calls XtEr-
rorMsg. XtNewString is a convenience macro that calls XtMalloc with the following arguments specified:
(strcpy(XtMalloc((unsigned) strlen(str) + 1), str))
SEE ALSO
X Toolkit Intrinsics - C Language Interface
Xlib - C Language X Interface
X Version 11 libXt 1.0.5 XtMalloc(3)
HI,
From a Windows XP machine I am doing an 'rsh' to a AIX system,I have updated .rhosts of AIX system with the remote system name and I could able to do a remote shell,but when i do the 'rsh' i am not getting the environment variables which is already set for the user in th AIX system in my rsh... (2 Replies)
Discussion started by: cherryven
2 Replies
3. Post Here to Contact Site Administrators and Moderators
Hi Mods,
Next Thread link available at the bottom, doesn't seem to be working accurately during a search, it goes to nextnewest thread relative to the thread we are viewing. Hope this can be fixed.
Regards,
Tayyab (4 Replies)
I meant old not hold :)
I need to kill a process if it's over an hour old and then send an e-mail of the list that was killed.....?
I need to kill ps -ef | grep stashd | grep ' older than an hour?'
#! /bin/bash
if test ps -ef | grep <stashd> (Is over an hour old)???? >>stashd_old.txt
... (9 Replies)
I can't tell what the output of the netstat command means. Is there anywhere that has this information? I tried the man pages, but they weren't helpful. (3 Replies)
This is related to one of my previous post.. I have huge file currently I am using loop to read file and checking each line to build this single record, its taking much much time to parse those records.. I thought there should be a way to do this in awk or sed.
I found this code in this forum... (7 Replies)
gnus doesn't seem to work for me. I tried giving it a couple different servers in the GNUs config file, including textnews.news.cambrium.nl and news.gnus.org. The first one I've used before, through Lynx with the nntp:// scheme (not the news: scheme). When I try starting gnus, it gives the... (1 Reply)