Debian Codegraph @

docs/api_reference/C/envset_alloc.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>DB_ENV-&gt;set_alloc()</title>
7 <link rel="stylesheet" href="apiReference.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" />
10 <link rel="up" href="env.html" title="Chapter 5.  The DB_ENV Handle" />
11 <link rel="prev" href="envremove.html" title="DB_ENV-&gt;remove()" />
12 <link rel="next" href="envset_app_dispatch.html" title="DB_ENV-&gt;set_app_dispatch()" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">DB_ENV-&gt;set_alloc()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="envremove.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 5. 
26 The DB_ENV Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="envset_app_dispatch.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="envset_alloc"></a>DB_ENV-&gt;set_alloc()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_ENV-&gt;set_alloc(DB_ENV *dbenv,
45 void *(*app_malloc)(size_t),
46 void *(*app_realloc)(void *, size_t),
47 void (*app_free)(void *)); </pre>
48 <p>
49 Set the allocation functions used by the <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a> and
50 <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a> methods to allocate or free
51 memory owned by the application.
52 </p>
53 <p>
54 There are a number of interfaces in Berkeley DB where memory is
55 allocated by the library and then given to the application. For
56 example, the <a class="link" href="dbt.html#dbt_DB_DBT_MALLOC">DB_DBT_MALLOC</a>
57 flag, when specified in the <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a>
58 object, will cause the <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a> methods to allocate and
59 reallocate memory which then becomes the responsibility of the calling
60 application. Other examples are the Berkeley DB interfaces
61 which return statistical information to the application:
62 <a class="xref" href="dbstat.html" title="DB-&gt;stat()">DB-&gt;stat()</a>,
63 <a class="xref" href="lockstat.html" title="DB_ENV-&gt;lock_stat()">DB_ENV-&gt;lock_stat()</a>,
64 <a class="xref" href="logarchive.html" title="DB_ENV-&gt;log_archive()">DB_ENV-&gt;log_archive()</a>,
65 <a class="xref" href="logstat.html" title="DB_ENV-&gt;log_stat()">DB_ENV-&gt;log_stat()</a>,
66 <a class="xref" href="mempstat.html" title="DB_ENV-&gt;memp_stat()">DB_ENV-&gt;memp_stat()</a>, and
67 <a class="xref" href="txnstat.html" title="DB_ENV-&gt;txn_stat()">DB_ENV-&gt;txn_stat()</a>. There is
68 one method in Berkeley DB where memory is allocated by the application
69 and then given to the library: the callback specified to
70 <a class="xref" href="dbassociate.html" title="DB-&gt;associate()">DB-&gt;associate()</a>.
71 </p>
72 <p>
73 On systems in which there may be multiple library versions of the
74 standard allocation routines (notably Windows NT), transferring memory
75 between the library and the application will fail because the Berkeley
76 DB library allocates memory from a different heap than the application
77 uses to free it. To avoid this problem, the <code class="methodname">DB_ENV-&gt;set_alloc()</code> and
78 <a class="xref" href="dbset_alloc.html" title="DB-&gt;set_alloc()">DB-&gt;set_alloc()</a>
79 methods can be used to pass Berkeley DB references to the
80 application's allocation routines.
81 </p>
82 <p>
83 It is not an error to specify only one or two of the possible
84 allocation function parameters to these interfaces; however, in that
85 case the specified interfaces must be compatible with the standard
86 library interfaces, as they will be used together. The functions
87 specified must match the calling conventions of the ANSI C X3.159-1989
88 (ANSI C) library routines of the same name.
89 </p>
90 <p>
91 The <code class="methodname">DB_ENV-&gt;set_alloc()</code> method configures operations performed using
92 the specified <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>
93 handle, not all operations performed on the underlying database
94 environment.
95 </p>
96 <p>
97 The <code class="methodname">DB_ENV-&gt;set_alloc()</code> method may not be called after the
98 <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a> method is called.
99 </p>
100 <p>
101 The <code class="methodname">DB_ENV-&gt;set_alloc()</code> <span>
102 <span>
103 method returns a non-zero error value on failure and 0 on success.
104 </span>
105
106 </span>
107 </p>
108 <div class="sect2" lang="en" xml:lang="en">
109 <div class="titlepage">
110 <div>
111 <div>
112 <h3 class="title"><a id="idp51733120"></a>Parameters</h3>
113 </div>
114 </div>
115 </div>
116 <div class="sect3" lang="en" xml:lang="en">
117 <div class="titlepage">
118 <div>
119 <div>
120 <h4 class="title"><a id="idp51733504"></a>app_malloc</h4>
121 </div>
122 </div>
123 </div>
124 <p>
125 The <span class="bold"><strong>app_malloc</strong></span> parameter is the
126 application-specified malloc function.
127 </p>
128 </div>
129 <div class="sect3" lang="en" xml:lang="en">
130 <div class="titlepage">
131 <div>
132 <div>
133 <h4 class="title"><a id="idp51760112"></a>app_realloc</h4>
134 </div>
135 </div>
136 </div>
137 <p>
138 The <span class="bold"><strong>app_realloc</strong></span> parameter is the
139 application-specified realloc function.
140 </p>
141 </div>
142 <div class="sect3" lang="en" xml:lang="en">
143 <div class="titlepage">
144 <div>
145 <div>
146 <h4 class="title"><a id="idp51769016"></a>app_free</h4>
147 </div>
148 </div>
149 </div>
150 <p>
151 The <span class="bold"><strong>app_free</strong></span> parameter is the
152 application-specified free function.
153 </p>
154 </div>
155 </div>
156 <div class="sect2" lang="en" xml:lang="en">
157 <div class="titlepage">
158 <div>
159 <div>
160 <h3 class="title"><a id="idp51783632"></a>Errors</h3>
161 </div>
162 </div>
163 </div>
164 <p>
165 The <code class="methodname">DB_ENV-&gt;set_alloc()</code> <span>
166 <span>
167 method may fail and return one of the following non-zero errors:
168 </span>
169
170 </span>
171 </p>
172 <div class="sect3" lang="en" xml:lang="en">
173 <div class="titlepage">
174 <div>
175 <div>
176 <h4 class="title"><a id="idp51788424"></a>EINVAL</h4>
177 </div>
178 </div>
179 </div>
180 <p>
181 If the method was called after <a class="xref" href="envopen.html" title="DB_ENV-&gt;open()">DB_ENV-&gt;open()</a>
182 was called; or if an invalid flag value or parameter was specified.
183 </p>
184 </div>
185 </div>
186 <div class="sect2" lang="en" xml:lang="en">
187 <div class="titlepage">
188 <div>
189 <div>
190 <h3 class="title"><a id="idp51789760"></a>Class</h3>
191 </div>
192 </div>
193 </div>
194 <p>
195 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>
196 </p>
197 </div>
198 <div class="sect2" lang="en" xml:lang="en">
199 <div class="titlepage">
200 <div>
201 <div>
202 <h3 class="title"><a id="idp51784312"></a>See Also</h3>
203 </div>
204 </div>
205 </div>
206 <p>
207 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a>
208 </p>
209 </div>
210 </div>
211 <div class="navfooter">
212 <hr />
213 <table width="100%" summary="Navigation footer">
214 <tr>
215 <td width="40%" align="left"><a accesskey="p" href="envremove.html">Prev</a> </td>
216 <td width="20%" align="center">
217 <a accesskey="u" href="env.html">Up</a>
218 </td>
219 <td width="40%" align="right"> <a accesskey="n" href="envset_app_dispatch.html">Next</a></td>
220 </tr>
221 <tr>
222 <td width="40%" align="left" valign="top">DB_ENV-&gt;remove() </td>
223 <td width="20%" align="center">
224 <a accesskey="h" href="index.html">Home</a>
225 </td>
226 <td width="40%" align="right" valign="top"> DB_ENV-&gt;set_app_dispatch()</td>
227 </tr>
228 </table>
229 </div>
230 </body>
231 </html>