XtNewString() XtNewString()
Name
XtNewString - copy an instance of a string.
Synopsis
String XtNewString(string)
String string;
Inputs
string Specifies 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 insuffi-
cient 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 AlsoXtMalloc(1), XtFree(1), XtNew(1).
Xt - Memory Allocation XtNewString()
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)
Introduction
I have seen some misinformation regarding Unix file permissions. I will try to set the record straight. Take a look at this example of some output from ls:
$ ls -ld /usr/bin /usr/bin/cat
drwxrwxr-x 3 root bin 8704 Sep 23 2004 /usr/bin
-r-xr-xr-x 1 bin bin ... (6 Replies)
I used to use ls -l cut to detrmine file size, and google searches didn't come up with anything else but 'stat' which doesn't appear on HPUX.
I discovered the humble 'wc -c' which does this job very neatly, and thought I would share it. (7 Replies)
Hi everyone,
I know the following questions are noobish questions but I am asking them because I am confused about the basics of history behind UNIX and LINUX.
Ok onto business, my questions are-:
Was/Is UNIX ever an open source operating system ?
If UNIX was... (21 Replies)
Hello guys,
I have problem with hpux shell script. I have one big text file that contains like
SOH
bla bla bla
bla bla bla
ETX SOH
bla bla bla
ETX
SOH
bla bla bla
ETX
What I need to do is save first SOH*BLA into file1.txt, save second SOH*BLA into file2.txt and so on.... (17 Replies)
Hi,
I am very new to HP-UX, and we're going to be doing a SAN migration.
We're going to take down the machine, and zone it to the new SAN.
My question is, will the device names change and will that interfere with the LVM?
If the new disks come in with different device names, how would I... (3 Replies)
i want to extract specific region of interest from big file. i have only start position, end position and seq id, see my query is:
I have file1 is this
>GL3482.1
GAACTTGAGATCCGGGGA
GCAGTGGATCTCCACCAG
CGGCCAGAACTGGTGCAC
CTCCAGGCCAGCCTCGTC
CTGCGTGTC
>GL3550.1... (14 Replies)
I require Hpux 11iv3 administration document if anyone could assist with the same it would be a great help. The Hp site does not have any consolidated document that could be referred to. I require something in line that could assist with network configuration and more. I require the same for Build... (3 Replies)
Got a raise and a formal position of 'unix system engineer' in 2016.
I would like to thank you members and admins.
This would not be possible without you.
I will mention some..
Thank you Don, for making me learn and understand the importance of standards, which i try to apply as much as i... (3 Replies)
Greetings Experts,
As part of automating the sql generation, I have the source table name, target table name, join condition stored in a file join_conditions.txt which is a delimited file (I can edit the file if for any reason). The reason I needed to store is I have built SELECT list without... (5 Replies)
Hi ,
I have to use HP-unix OS to get difference between 2 files.while i tried a piece of code in other OS(linux/unix) as below, it worked fine & the output is desired one.
diff --suppress-common-lines -y file_1 file_2 >d.txt
The same doesn't works in HP -unix. Any help shall be... (6 Replies)
hi folks,
how to using tar with exclude directory and compress it using tar.Z
i only know how to exclude dir only with this command below:
tar -cvf /varios/restore/test.tar -X excludefile.txt /jfma/test1/
how to compress it using 1 command?
Thanx
Please use CODE tags as... (6 Replies)
Back in my early days, just starting at my first job where I was doing 100% UNIX...
We had a mixture of Solaris, AIX, and HPUX systems. Our most critical systems (Logistics) was running on a bunch of large HP 9000 servers. I was tasked with decommisoning one of the servers.
It was one... (5 Replies)
Hello!
Yesterday we added over 10,000 PHP man pages to our man page section.
I've not yet got our unique and special recursive search feature working; but you can still access the PHP man pages directly by selecting PHP in the man sets drop down menu (left side) and then section 3 (right... (3 Replies)
What is the point of this? Whenever I close my shell it appends to the history file without adding this. I have never seen it overwrite my history file.
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend (3 Replies)