1XtMalloc(3) XT FUNCTIONS XtMalloc(3)
2
3
4
6 XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString - memory man‐
7 agement functions
8
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
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
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
47 allocate 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 the allocated storage. If there is
72 insufficient memory to allocate the new block, XtNewString calls XtEr‐
73 rorMsg. XtNewString is a convenience macro that calls XtMalloc with
74 the following arguments specified:
75
76 (strcpy(XtMalloc((unsigned) strlen(str) + 1), str))
77
78 The XtAsprintf function allocates space for a string large enough to
79 hold the string specified by the sprintf(3c) format pattern when used
80 with the remaining arguments, and fills it with the formatted results.
81 The address of the allocated string is placed into the pointer passed
82 as ret. The length of the string (not including the terminating null
83 byte) is returned. If there is insufficient memory to allocate the new
84 block, XtAsprintf calls XtErrorMsg.
85
87 X Toolkit Intrinsics - C Language Interface
88 Xlib - C Language X Interface
89
90
91
92X Version 11 libXt 1.1.5.1 XtMalloc(3)