Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xtnew(1) [hpux man page]

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 Also
  XtMalloc(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)
Man Page

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replacing multiple lines

i have a file : sample1.txt OBJECT="POINT" ACTION="REDEFINE" POINT_NAME="ABCD001G " GHYT_POPRIORITY_1="1" GHYT_POPRIORITY_2="1" GHYT_POPRIORITY_3="1" GHYT_POPRIORITY_4="1" GHYT_POPRIORITY_USER="1" HIGH_ALARM_PRIORITY_1="1" HIGH_ALARM_PRIORITY_2="1" HIGH_ALARM_PRIORITY_3="1" ... (1 Reply)
Discussion started by: ajnabi
1 Replies

2. AIX

Environment variables in 'rsh'

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

Thread browsing during search

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)
Discussion started by: tayyabq8
4 Replies

4. Solaris

Kill a particular process if it's over an hour hold

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)
Discussion started by: xgringo
9 Replies

5. IP Networking

netstat output

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)
Discussion started by: Ultrix
3 Replies

6. Shell Programming and Scripting

Awk multiple lines with 4th column on to a single line

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)
Discussion started by: Vasan
7 Replies

7. UNIX for Dummies Questions & Answers

How do you get gnus to work?

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)
Discussion started by: Ultrix
1 Replies