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