Blame man/XtMalloc.man

Packit 0d0b0c
.\" Copyright 1993 X Consortium
Packit 0d0b0c
.\"
Packit 0d0b0c
.\" Permission is hereby granted, free of charge, to any person obtaining
Packit 0d0b0c
.\" a copy of this software and associated documentation files (the
Packit 0d0b0c
.\" "Software"), to deal in the Software without restriction, including
Packit 0d0b0c
.\" without limitation the rights to use, copy, modify, merge, publish,
Packit 0d0b0c
.\" distribute, sublicense, and/or sell copies of the Software, and to
Packit 0d0b0c
.\" permit persons to whom the Software is furnished to do so, subject to
Packit 0d0b0c
.\" the following conditions:
Packit 0d0b0c
.\"
Packit 0d0b0c
.\" The above copyright notice and this permission notice shall be
Packit 0d0b0c
.\" included in all copies or substantial portions of the Software.
Packit 0d0b0c
.\"
Packit 0d0b0c
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 0d0b0c
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 0d0b0c
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Packit 0d0b0c
.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
Packit 0d0b0c
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Packit 0d0b0c
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Packit 0d0b0c
.\" OTHER DEALINGS IN THE SOFTWARE.
Packit 0d0b0c
.\"
Packit 0d0b0c
.\" Except as contained in this notice, the name of the X Consortium shall
Packit 0d0b0c
.\" not be used in advertising or otherwise to promote the sale, use or
Packit 0d0b0c
.\" other dealings in this Software without prior written authorization
Packit 0d0b0c
.\" from the X Consortium.
Packit 0d0b0c
.\"
Packit 0d0b0c
.ds tk X Toolkit
Packit 0d0b0c
.ds xT X Toolkit Intrinsics \- C Language Interface
Packit 0d0b0c
.ds xI Intrinsics
Packit 0d0b0c
.ds xW X Toolkit Athena Widgets \- C Language Interface
Packit 0d0b0c
.ds xL Xlib \- C Language X Interface
Packit 0d0b0c
.ds xC Inter-Client Communication Conventions Manual
Packit 0d0b0c
.ds Rn 3
Packit 0d0b0c
.ds Vn 2.2
Packit 0d0b0c
.hw XtNew-String wid-get
Packit 0d0b0c
.na
Packit 0d0b0c
.de Ds
Packit 0d0b0c
.nf
Packit 0d0b0c
.\\$1D \\$2 \\$1
Packit 0d0b0c
.ft CW
Packit 0d0b0c
.ps \\n(PS
Packit 0d0b0c
.\".if \\n(VS>=40 .vs \\n(VSu
Packit 0d0b0c
.\".if \\n(VS<=39 .vs \\n(VSp
Packit 0d0b0c
..
Packit 0d0b0c
.de De
Packit 0d0b0c
.ce 0
Packit 0d0b0c
.if \\n(BD .DF
Packit 0d0b0c
.nr BD 0
Packit 0d0b0c
.in \\n(OIu
Packit 0d0b0c
.if \\n(TM .ls 2
Packit 0d0b0c
.sp \\n(DDu
Packit 0d0b0c
.fi
Packit 0d0b0c
..
Packit 0d0b0c
.de IN		\" send an index entry to the stderr
Packit 0d0b0c
..
Packit 0d0b0c
.de Pn
Packit 0d0b0c
.ie t \\$1\fB\^\\$2\^\fR\\$3
Packit 0d0b0c
.el \\$1\fI\^\\$2\^\fP\\$3
Packit 0d0b0c
..
Packit 0d0b0c
.de ZN
Packit 0d0b0c
.ie t \fB\^\\$1\^\fR\\$2
Packit 0d0b0c
.el \fI\^\\$1\^\fP\\$2
Packit 0d0b0c
..
Packit 0d0b0c
.ny0
Packit 0d0b0c
.TH XtMalloc __libmansuffix__ __xorgversion__ "XT FUNCTIONS"
Packit 0d0b0c
.SH NAME
Packit 0d0b0c
XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString \- memory management functions
Packit 0d0b0c
.SH SYNTAX
Packit 0d0b0c
.HP
Packit 0d0b0c
char *XtMalloc(Cardinal \fIsize\fP);
Packit 0d0b0c
.HP
Packit 0d0b0c
char *XtCalloc(Cardinal \fInum\fP, Cardinal \fIsize\fP);
Packit 0d0b0c
.HP
Packit 0d0b0c
char *XtRealloc(char *\fIptr\fP, Cardinal \fInum\fP);
Packit 0d0b0c
.HP
Packit 0d0b0c
void XtFree(char *\fIptr\fP);
Packit 0d0b0c
.HP
Packit 0d0b0c
\fItype\fP *XtNew(\fItype\fP);
Packit 0d0b0c
.HP
Packit 0d0b0c
String XtNewString(String \fIstring\fP);
Packit 0d0b0c
.HP
Packit 0d0b0c
Cardinal XtAsprintf(String *\fInew_string\fP, const char *\fIformat\fP, ...);
Packit 0d0b0c
.SH ARGUMENTS
Packit 0d0b0c
.IP \fInum\fP 1i
Packit 0d0b0c
Specifies the number of bytes or array elements.
Packit 0d0b0c
.ds Po to the old storage or to the block of storage that is to be freed
Packit 0d0b0c
.IP \fIptr\fP 1i
Packit 0d0b0c
Specifies a pointer \*(Po.
Packit 0d0b0c
.IP \fIsize\fP 1i
Packit 0d0b0c
Specifies the size of an array element (in bytes) or the number of bytes
Packit 0d0b0c
desired.
Packit 0d0b0c
.IP \fIstring\fP 1i
Packit 0d0b0c
Specifies a previously declared string.
Packit 0d0b0c
.IP \fItype\fP 1i
Packit 0d0b0c
Specifies a previously declared data type.
Packit 0d0b0c
.IP \fInew_string\fP 1i
Packit 0d0b0c
Specifies a pointer to write a newly allocated string to.
Packit 0d0b0c
.IP \fIformat\fP 1i
Packit 0d0b0c
Specifies a formatting string as defined by sprintf(3c)
Packit 0d0b0c
.SH DESCRIPTION
Packit 0d0b0c
The
Packit 0d0b0c
.ZN XtMalloc
Packit 0d0b0c
functions returns a pointer to a block of storage of at least
Packit 0d0b0c
the specified size bytes.
Packit 0d0b0c
If there is insufficient memory to allocate the new block,
Packit 0d0b0c
.ZN XtMalloc
Packit 0d0b0c
calls
Packit 0d0b0c
.ZN XtErrorMsg .
Packit 0d0b0c
.LP
Packit 0d0b0c
The
Packit 0d0b0c
.ZN XtCalloc
Packit 0d0b0c
function allocates space for the specified number of array elements
Packit 0d0b0c
of the specified size and initializes the space to zero.
Packit 0d0b0c
If there is insufficient memory to allocate the new block,
Packit 0d0b0c
.ZN XtCalloc
Packit 0d0b0c
calls
Packit 0d0b0c
.ZN XtErrorMsg .
Packit 0d0b0c
.LP
Packit 0d0b0c
The
Packit 0d0b0c
.ZN XtRealloc
Packit 0d0b0c
function changes the size of a block of storage (possibly moving it).
Packit 0d0b0c
Then, it copies the old contents (or as much as will fit) into the new block
Packit 0d0b0c
and frees the old block.
Packit 0d0b0c
If there is insufficient memory to allocate the new block,
Packit 0d0b0c
.ZN XtRealloc
Packit 0d0b0c
calls
Packit 0d0b0c
.ZN XtErrorMsg .
Packit 0d0b0c
If ptr is NULL,
Packit 0d0b0c
.ZN XtRealloc
Packit 0d0b0c
allocates the new storage without copying the old contents;
Packit 0d0b0c
that is, it simply calls
Packit 0d0b0c
.ZN XtMalloc .
Packit 0d0b0c
.LP
Packit 0d0b0c
The
Packit 0d0b0c
.ZN XtFree
Packit 0d0b0c
function returns storage and allows it to be reused.
Packit 0d0b0c
If ptr is NULL,
Packit 0d0b0c
.ZN XtFree
Packit 0d0b0c
returns immediately.
Packit 0d0b0c
.LP
Packit 0d0b0c
.ZN XtNew
Packit 0d0b0c
returns a pointer to the allocated storage.
Packit 0d0b0c
If there is insufficient memory to allocate the new block,
Packit 0d0b0c
.ZN XtNew
Packit 0d0b0c
calls
Packit 0d0b0c
.ZN XtErrorMsg .
Packit 0d0b0c
.ZN XtNew
Packit 0d0b0c
is a convenience macro that calls
Packit 0d0b0c
.ZN XtMalloc
Packit 0d0b0c
with the following arguments specified:
Packit 0d0b0c
.LP
Packit 0d0b0c
.Ds
Packit 0d0b0c
.TA .5i
Packit 0d0b0c
.ta .5i
Packit 0d0b0c
((type *) XtMalloc((unsigned) sizeof(type))
Packit 0d0b0c
.De
Packit 0d0b0c
.LP
Packit 0d0b0c
.ZN XtNewString
Packit 0d0b0c
returns a pointer to the allocated storage.
Packit 0d0b0c
If there is insufficient memory to allocate the new block,
Packit 0d0b0c
.ZN XtNewString
Packit 0d0b0c
calls
Packit 0d0b0c
.ZN XtErrorMsg .
Packit 0d0b0c
.ZN XtNewString
Packit 0d0b0c
is a convenience macro that calls
Packit 0d0b0c
.ZN XtMalloc
Packit 0d0b0c
with the following arguments specified:
Packit 0d0b0c
.LP
Packit 0d0b0c
.Ds
Packit 0d0b0c
.TA .5i
Packit 0d0b0c
.ta .5i
Packit 0d0b0c
(strcpy(XtMalloc((unsigned) strlen(str) + 1), str))
Packit 0d0b0c
.De
Packit 0d0b0c
.LP
Packit 0d0b0c
The
Packit 0d0b0c
.ZN XtAsprintf
Packit 0d0b0c
function allocates space for a string large enough to hold the string
Packit 0d0b0c
specified by the sprintf(3c) format pattern when used with the remaining
Packit 0d0b0c
arguments, and fills it with the formatted results.
Packit 0d0b0c
The address of the allocated string is placed into the pointer passed as ret.
Packit 0d0b0c
The length of the string (not including the terminating null byte) is returned.
Packit 0d0b0c
If there is insufficient memory to allocate the new block,
Packit 0d0b0c
.ZN XtAsprintf
Packit 0d0b0c
calls
Packit 0d0b0c
.ZN XtErrorMsg .
Packit 0d0b0c
.SH "SEE ALSO"
Packit 0d0b0c
.br
Packit 0d0b0c
\fI\*(xT\fP
Packit 0d0b0c
.br
Packit 0d0b0c
\fI\*(xL\fP