~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/erl_interface/doc/src/erl_malloc.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE cref SYSTEM "cref.dtd">
 
3
 
 
4
<cref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1996</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>erl_malloc</title>
 
27
    <prepared>Torbj&ouml;rn T&ouml;rnkvist</prepared>
 
28
    <responsible>Torbj&ouml;rn T&ouml;rnkvist</responsible>
 
29
    <docno></docno>
 
30
    <approved>Bjarne D&auml;cker</approved>
 
31
    <checked>Torbj&ouml;rn T&ouml;rnkvist</checked>
 
32
    <date>980703</date>
 
33
    <rev>A</rev>
 
34
    <file>erl_malloc.sgml</file>
 
35
  </header>
 
36
  <lib>erl_malloc</lib>
 
37
  <libsummary>Memory Allocation Functions</libsummary>
 
38
  <description>
 
39
    <p>This module provides functions for allocating and deallocating
 
40
      memory.</p>
 
41
  </description>
 
42
  <funcs>
 
43
    <func>
 
44
      <name><ret>ETERM *</ret><nametext>erl_alloc_eterm(etype)</nametext></name>
 
45
      <fsummary>Allocates an ETERM structure</fsummary>
 
46
      <type>
 
47
        <v>unsigned char etype;</v>
 
48
      </type>
 
49
      <desc>
 
50
        <p>This function allocates an <c><![CDATA[(ETERM)]]></c> structure.
 
51
          Specify <c><![CDATA[etype]]></c> as one of the following constants:</p>
 
52
        <list type="bulleted">
 
53
          <item>
 
54
            <p>ERL_INTEGER</p>
 
55
          </item>
 
56
          <item>
 
57
            <p>ERL_U_INTEGER <c><![CDATA[/* unsigned integer */]]></c></p>
 
58
          </item>
 
59
          <item>
 
60
            <p>ERL_ATOM</p>
 
61
          </item>
 
62
          <item>
 
63
            <p>ERL_PID <c><![CDATA[/* Erlang process identifier */]]></c></p>
 
64
          </item>
 
65
          <item>
 
66
            <p>ERL_PORT</p>
 
67
          </item>
 
68
          <item>
 
69
            <p>ERL_REF <c><![CDATA[/* Erlang reference */]]></c></p>
 
70
          </item>
 
71
          <item>
 
72
            <p>ERL_LIST</p>
 
73
          </item>
 
74
          <item>
 
75
            <p>ERL_EMPTY_LIST</p>
 
76
          </item>
 
77
          <item>
 
78
            <p>ERL_TUPLE</p>
 
79
          </item>
 
80
          <item>
 
81
            <p>ERL_BINARY</p>
 
82
          </item>
 
83
          <item>
 
84
            <p>ERL_FLOAT</p>
 
85
          </item>
 
86
          <item>
 
87
            <p>ERL_VARIABLE</p>
 
88
          </item>
 
89
          <item>
 
90
            <p>ERL_SMALL_BIG <c><![CDATA[/* bignum */]]></c></p>
 
91
          </item>
 
92
          <item>
 
93
            <p>ERL_U_SMALL_BIG <c><![CDATA[/* bignum */]]></c></p>
 
94
          </item>
 
95
        </list>
 
96
        <p><c><![CDATA[ERL_SMALL_BIG]]></c> and <c><![CDATA[ERL_U_SMALL_BIG]]></c> are for
 
97
          creating Erlang <c><![CDATA[bignums]]></c>, which can contain integers of
 
98
          arbitrary size. The size of an integer in Erlang is machine
 
99
          dependent, but in general any integer larger than 2^28
 
100
          requires a bignum.</p>
 
101
      </desc>
 
102
    </func>
 
103
    <func>
 
104
      <name><ret>void</ret><nametext>erl_eterm_release(void)</nametext></name>
 
105
      <fsummary>Clears the ETERM freelist</fsummary>
 
106
      <desc>
 
107
        <p>Clears the 
 
108
          freelist, where blocks are placed when they are
 
109
          released by <c><![CDATA[erl_free_term()]]></c> and
 
110
          <c><![CDATA[erl_free_compound()]]></c>. </p>
 
111
      </desc>
 
112
    </func>
 
113
    <func>
 
114
      <name><ret>void</ret><nametext>erl_eterm_statistics(allocated, freed)</nametext></name>
 
115
      <fsummary>Reports term allocation statistics</fsummary>
 
116
      <type>
 
117
        <v>long *allocated;</v>
 
118
        <v>long *freed;</v>
 
119
      </type>
 
120
      <desc>
 
121
        <p><c><![CDATA[allocated]]></c> and <c><![CDATA[freed]]></c> are initialized to
 
122
          contain information about the fix-allocator used to allocate
 
123
          ETERM components. <c><![CDATA[allocated]]></c> is the number of blocks
 
124
          currently allocated to ETERM objects. <c><![CDATA[freed]]></c> is the
 
125
          length of the freelist, where blocks are placed when they are
 
126
          released by <c><![CDATA[erl_free_term()]]></c> and
 
127
          <c><![CDATA[erl_free_compound()]]></c>. </p>
 
128
      </desc>
 
129
    </func>
 
130
    <func>
 
131
      <name><ret>void</ret><nametext>erl_free_array(array, size)</nametext></name>
 
132
      <fsummary>Frees an array of ETERM structures</fsummary>
 
133
      <type>
 
134
        <v>ETERM **array;</v>
 
135
        <v>int size;</v>
 
136
      </type>
 
137
      <desc>
 
138
        <p>This function frees an array of Erlang terms.</p>
 
139
        <p><c><![CDATA[array]]></c> is an array of ETERM* objects.
 
140
          </p>
 
141
        <p><c><![CDATA[size]]></c> is the number of terms in the array.</p>
 
142
      </desc>
 
143
    </func>
 
144
    <func>
 
145
      <name><ret>void</ret><nametext>erl_free_term(t)</nametext></name>
 
146
      <fsummary>Frees an ETERM structure</fsummary>
 
147
      <type>
 
148
        <v>ETERM *t;</v>
 
149
      </type>
 
150
      <desc>
 
151
        <p>Use this function to free an Erlang term.</p>
 
152
      </desc>
 
153
    </func>
 
154
    <func>
 
155
      <name><ret>void</ret><nametext>erl_free_compound(t)</nametext></name>
 
156
      <fsummary>Frees an array of ETERM structures</fsummary>
 
157
      <type>
 
158
        <v>ETERM *t;</v>
 
159
      </type>
 
160
      <desc>
 
161
        <p>Normally it is the programmer's responsibility to free each
 
162
          Erlang term that has been returned from any of the
 
163
          <c><![CDATA[erl_interface]]></c> functions. However since many of the
 
164
          functions that build new Erlang terms in fact share objects
 
165
          with other existing terms, it may be difficult for the
 
166
          programmer to maintain pointers to all such terms in order to
 
167
          free them individually.
 
168
          </p>
 
169
        <p><c><![CDATA[erl_free_compound()]]></c> will recursively free all of the
 
170
          sub-terms associated with a given Erlang term, regardless of
 
171
          whether we are still holding pointers to the sub-terms.
 
172
          </p>
 
173
        <p>There is an example in the User Manual under "Building
 
174
          Terms and Patterns"
 
175
          </p>
 
176
      </desc>
 
177
    </func>
 
178
    <func>
 
179
      <name><ret>void</ret><nametext>erl_malloc(size)</nametext></name>
 
180
      <fsummary>Allocates some memory</fsummary>
 
181
      <type>
 
182
        <v>long size;</v>
 
183
      </type>
 
184
      <desc>
 
185
        <p>This function calls the standard 
 
186
          <c><![CDATA[malloc()]]></c> function. </p>
 
187
      </desc>
 
188
    </func>
 
189
    <func>
 
190
      <name><ret>void</ret><nametext>erl_free(ptr)</nametext></name>
 
191
      <fsummary>Frees some memory</fsummary>
 
192
      <type>
 
193
        <v>void *ptr;</v>
 
194
      </type>
 
195
      <desc>
 
196
        <p>This function calls the standard 
 
197
          <c><![CDATA[free()]]></c> function. </p>
 
198
      </desc>
 
199
    </func>
 
200
  </funcs>
 
201
</cref>
 
202