Debian Codegraph @

docs/api_reference/CXX/dbset_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::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="db.html" title="Chapter 2.  The Db Handle" />
11 <link rel="prev" href="dbrename.html" title="Db::rename()" />
12 <link rel="next" href="dbset_append_recno.html" title="Db::set_append_recno()" />
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::set_alloc()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbrename.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 2. 
26 The Db Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="dbset_append_recno.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="dbset_alloc"></a>Db::set_alloc()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 Db::set_alloc(db_malloc_fcn_type app_malloc,
45 db_realloc_fcn_type app_realloc,
46 db_free_fcn_type app_free);</pre>
47 <p>
48 Set the allocation functions used by the
49 <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</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. (See <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a>
61 for more information.) Other examples are the Berkeley DB interfaces
62 which return statistical information to the application:
63 <a class="xref" href="dbstat.html" title="Db::stat()">Db::stat()</a>,
64 <a class="xref" href="lockstat.html" title="DbEnv::lock_stat()">DbEnv::lock_stat()</a>,
65 <a class="xref" href="logarchive.html" title="DbEnv::log_archive()">DbEnv::log_archive()</a>,
66 <a class="xref" href="logstat.html" title="DbEnv::log_stat()">DbEnv::log_stat()</a>,
67 <a class="xref" href="mempstat.html" title="DbEnv::memp_stat()">DbEnv::memp_stat()</a>,
68 and <a class="xref" href="txnstat.html" title="DbEnv::txn_stat()">DbEnv::txn_stat()</a>. There is
69 one method in Berkeley DB where memory is allocated by the application
70 and then given to the library: <a class="xref" href="dbassociate.html" title="Db::associate()">Db::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
78 <a class="xref" href="envset_alloc.html" title="DbEnv::set_alloc()">DbEnv::set_alloc()</a> and
79 <code class="methodname">Db::set_alloc()</code> methods can be used to pass Berkeley DB references to
80 the 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 Because databases opened within Berkeley DB environments use the
92 allocation interfaces specified to the environment, it is an error to
93 attempt to set those interfaces in a database created within an
94 environment.
95 </p>
96 <p>
97 The <code class="methodname">Db::set_alloc()</code> method may not be called after the
98 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> method is called.
99 </p>
100 <p>
101 The <code class="methodname">Db::set_alloc()</code> <span>
102
103 <span>
104 method either returns a non-zero error value or throws an
105 exception that encapsulates a non-zero error value on
106 failure, and returns 0 on success.
107 </span>
108 </span>
109 </p>
110 <div class="sect2" lang="en" xml:lang="en">
111 <div class="titlepage">
112 <div>
113 <div>
114 <h3 class="title"><a id="idp5420104"></a>Errors</h3>
115 </div>
116 </div>
117 </div>
118 <p>
119 The <code class="methodname">Db::set_alloc()</code> <span>
120
121 <span>
122 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
123 exception, encapsulating one of the following non-zero errors, or return one
124 of the following non-zero errors:
125 </span>
126 </span>
127 </p>
128 <div class="sect3" lang="en" xml:lang="en">
129 <div class="titlepage">
130 <div>
131 <div>
132 <h4 class="title"><a id="idp5072224"></a>EINVAL</h4>
133 </div>
134 </div>
135 </div>
136 <p>
137 If called in a database environment, or called after
138 <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> was called; or if an
139 invalid flag value or parameter was specified.
140 </p>
141 </div>
142 </div>
143 <div class="sect2" lang="en" xml:lang="en">
144 <div class="titlepage">
145 <div>
146 <div>
147 <h3 class="title"><a id="idm1364360"></a>Class</h3>
148 </div>
149 </div>
150 </div>
151 <p>
152 <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
153 </p>
154 </div>
155 <div class="sect2" lang="en" xml:lang="en">
156 <div class="titlepage">
157 <div>
158 <div>
159 <h3 class="title"><a id="idm1994168"></a>See Also</h3>
160 </div>
161 </div>
162 </div>
163 <p>
164 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
165 </p>
166 </div>
167 </div>
168 <div class="navfooter">
169 <hr />
170 <table width="100%" summary="Navigation footer">
171 <tr>
172 <td width="40%" align="left"><a accesskey="p" href="dbrename.html">Prev</a> </td>
173 <td width="20%" align="center">
174 <a accesskey="u" href="db.html">Up</a>
175 </td>
176 <td width="40%" align="right"> <a accesskey="n" href="dbset_append_recno.html">Next</a></td>
177 </tr>
178 <tr>
179 <td width="40%" align="left" valign="top">Db::rename() </td>
180 <td width="20%" align="center">
181 <a accesskey="h" href="index.html">Home</a>
182 </td>
183 <td width="40%" align="right" valign="top"> Db::set_append_recno()</td>
184 </tr>
185 </table>
186 </div>
187 </body>
188 </html>