1XtMalloc(3)                      XT FUNCTIONS                      XtMalloc(3)
2
3
4

NAME

6       XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString - memory man‐
7       agement functions
8

SYNTAX

10       #include <X11/Intrinsic.h>
11
12       char *XtMalloc(Cardinal size);
13
14       char *XtCalloc(Cardinal num, Cardinal size);
15
16       char *XtRealloc(char *ptr, Cardinal num);
17
18       void XtFree(char *ptr);
19
20       type *XtNew(type);
21
22       String XtNewString(String string);
23
24       Cardinal XtAsprintf(char **new_string, const char *format, ...);
25

ARGUMENTS

27       num       Specifies the number of bytes or array elements.
28
29       ptr       Specifies a pointer to the old storage or to the block of
30                 storage that is to be freed.
31
32       size      Specifies the size of an array element (in bytes) or the num‐
33                 ber of bytes desired.
34
35       string    Specifies a previously declared string.
36
37       type      Specifies a previously declared data type.
38
39       new_string
40                 Specifies a pointer to write a newly allocated string to.
41
42       format    Specifies a formatting string as defined by sprintf(3c)
43

DESCRIPTION

45       The XtMalloc functions returns a pointer to a block of storage of at
46       least the specified size bytes.  If there is insufficient memory to al‐
47       locate the new block, XtMalloc calls XtErrorMsg.
48
49       The XtCalloc function allocates space for the specified number of array
50       elements of the specified size and initializes the space to zero.  If
51       there is insufficient memory to allocate the new block, XtCalloc calls
52       XtErrorMsg.
53
54       The XtRealloc function changes the size of a block of storage (possibly
55       moving it).  Then, it copies the old contents (or as much as will fit)
56       into the new block and frees the old block.  If there is insufficient
57       memory to allocate the new block, XtRealloc calls XtErrorMsg.  If ptr
58       is NULL, XtRealloc allocates the new storage without copying the old
59       contents; that is, it simply calls XtMalloc.
60
61       The XtFree function returns storage and allows it to be reused.  If ptr
62       is NULL, XtFree returns immediately.
63
64       XtNew returns a pointer to the allocated storage.  If there is insuffi‐
65       cient memory to allocate the new block, XtNew calls XtErrorMsg.  XtNew
66       is a convenience macro that calls XtMalloc with the following arguments
67       specified:
68
69            ((type *) XtMalloc((unsigned) sizeof(type))
70
71       XtNewString returns a pointer to a new string which is a duplicate of
72       string.  If there is insufficient memory to allocate the new block, or
73       the argument is NULL XtNewString returns NULL. The memory can be freed
74       with XtFree.
75
76       The XtAsprintf function allocates space for a string large enough to
77       hold the string specified by the sprintf(3c) format pattern when used
78       with the remaining arguments, and fills it with the formatted results.
79       The address of the allocated string is placed into the pointer passed
80       as ret.  The length of the string (not including the terminating null
81       byte) is returned.  If there is insufficient memory to allocate the new
82       block, XtAsprintf calls XtErrorMsg.
83

SEE ALSO

85       X Toolkit Intrinsics - C Language Interface
86       Xlib - C Language X Interface
87
88
89
90X Version 11                      libXt 1.2.1                      XtMalloc(3)
Impressum