1XtMalloc(3) XT FUNCTIONS XtMalloc(3)
2
3
4
6 XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString - memory man‐
7 agement functions
8
10 char *XtMalloc(Cardinal size);
11
12 char *XtCalloc(Cardinal num, Cardinal size);
13
14 char *XtRealloc(char *ptr, Cardinal num);
15
16 void XtFree(char *ptr);
17
18 type *XtNew(type);
19
20 String XtNewString(String string);
21
22 Cardinal XtAsprintf(String *new_string, const char *format, ...);
23
25 num Specifies the number of bytes or array elements.
26
27 ptr Specifies a pointer to the old storage or to the block of
28 storage that is to be freed.
29
30 size Specifies the size of an array element (in bytes) or the num‐
31 ber of bytes desired.
32
33 string Specifies a previously declared string.
34
35 type Specifies a previously declared data type.
36
37 new_string
38 Specifies a pointer to write a newly allocated string to.
39
40 format Specifies a formatting string as defined by sprintf(3c)
41
43 The XtMalloc functions returns a pointer to a block of storage of at
44 least the specified size bytes. If there is insufficient memory to
45 allocate the new block, XtMalloc calls XtErrorMsg.
46
47 The XtCalloc function allocates space for the specified number of array
48 elements of the specified size and initializes the space to zero. If
49 there is insufficient memory to allocate the new block, XtCalloc calls
50 XtErrorMsg.
51
52 The XtRealloc function changes the size of a block of storage (possibly
53 moving it). Then, it copies the old contents (or as much as will fit)
54 into the new block and frees the old block. If there is insufficient
55 memory to allocate the new block, XtRealloc calls XtErrorMsg. If ptr
56 is NULL, XtRealloc allocates the new storage without copying the old
57 contents; that is, it simply calls XtMalloc.
58
59 The XtFree function returns storage and allows it to be reused. If ptr
60 is NULL, XtFree returns immediately.
61
62 XtNew returns a pointer to the allocated storage. If there is insuffi‐
63 cient memory to allocate the new block, XtNew calls XtErrorMsg. XtNew
64 is a convenience macro that calls XtMalloc with the following arguments
65 specified:
66
67 ((type *) XtMalloc((unsigned) sizeof(type))
68
69 XtNewString returns a pointer to the allocated storage. If there is
70 insufficient memory to allocate the new block, XtNewString calls XtEr‐
71 rorMsg. XtNewString is a convenience macro that calls XtMalloc with
72 the following arguments specified:
73
74 (strcpy(XtMalloc((unsigned) strlen(str) + 1), str))
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
85 X Toolkit Intrinsics - C Language Interface
86 Xlib - C Language X Interface
87
88
89
90X Version 11 libXt 1.1.4 XtMalloc(3)