1erl_malloc(3) C Library Functions erl_malloc(3)
2
3
4
6 erl_malloc - Memory allocation functions.
7
9 Note:
10 The support for VxWorks is deprecated as of OTP 22, and will be removed
11 in OTP 23.
12
13
14 Note:
15 The old legacy erl_interface library (functions with prefix erl_) is
16 deprecated as of OTP 22, and will be removed in OTP 23. This does not
17 apply to the ei library. Reasonably new gcc compilers will issue depre‐
18 cation warnings. In order to disable these warnings, define the macro
19 EI_NO_DEPR_WARN.
20
21
22 This module provides functions for allocating and deallocating memory.
23
25 ETERM *erl_alloc_eterm(etype)
26
27 Types:
28
29 unsigned char etype;
30
31 Allocates an (ETERM) structure.
32
33 Specify etype as one of the following constants:
34
35 * ERL_INTEGER
36
37 * ERL_U_INTEGER (unsigned integer)
38
39 * ERL_ATOM
40
41 * ERL_PID (Erlang process identifier)
42
43 * ERL_PORT
44
45 * ERL_REF (Erlang reference)
46
47 * ERL_LIST
48
49 * ERL_EMPTY_LIST
50
51 * ERL_TUPLE
52
53 * ERL_BINARY
54
55 * ERL_FLOAT
56
57 * ERL_VARIABLE
58
59 * ERL_SMALL_BIG (bignum)
60
61 * ERL_U_SMALL_BIG (bignum)
62
63 ERL_SMALL_BIG and ERL_U_SMALL_BIG are for creating Erlang
64 bignums, which can contain integers of any size. The size of an
65 integer in Erlang is machine-dependent, but any integer > 2^28
66 requires a bignum.
67
68 void erl_eterm_release(void)
69
70 Clears the freelist, where blocks are placed when they are
71 released by erl_free_term() and erl_free_compound().
72
73 void erl_eterm_statistics(allocated, freed)
74
75 Types:
76
77 long *allocated;
78 long *freed;
79
80 Reports term allocation statistics.
81
82 allocated and freed are initialized to contain information about
83 the fix-allocator used to allocate ETERM components.
84
85 * allocated is the number of blocks currently allocated to
86 ETERM objects.
87
88 * freed is the length of the freelist, where blocks are placed
89 when they are released by erl_free_term() and erl_free_com‐
90 pound().
91
92 void erl_free(ptr)
93
94 Types:
95
96 void *ptr;
97
98 Calls the standard free() function.
99
100 void erl_free_array(array, size)
101
102 Types:
103
104 ETERM **array;
105 int size;
106
107 Frees an array of Erlang terms.
108
109 * array is an array of ETERM* objects.
110
111 * size is the number of terms in the array.
112
113 void erl_free_compound(t)
114
115 Types:
116
117 ETERM *t;
118
119 Normally it is the programmer's responsibility to free each
120 Erlang term that has been returned from any of the Erl_Interface
121 functions. However, as many of the functions that build new
122 Erlang terms in fact share objects with other existing terms, it
123 can be difficult for the programmer to maintain pointers to all
124 such terms to free them individually.
125
126 erl_free_compound() recursively frees all of the subterms asso‐
127 ciated with a specified Erlang term, regardless of whether we
128 are still holding pointers to the subterms.
129
130 For an example, see section Building Terms and Patterns in the
131 User's Guide.
132
133 void erl_free_term(t)
134
135 Types:
136
137 ETERM *t;
138
139 Frees an Erlang term.
140
141 void erl_malloc(size)
142
143 Types:
144
145 long size;
146
147 Calls the standard malloc() function.
148
149
150
151Ericsson AB erl_interface 3.13 erl_malloc(3)