Debian Codegraph @

docs/api_reference/C/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-&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="db.html" title="Chapter 2.  The DB Handle" />
11 <link rel="prev" href="dbrename.html" title="DB-&gt;rename()" />
12 <link rel="next" href="dbset_append_recno.html" title="DB-&gt;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-&gt;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-&gt;set_alloc()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB-&gt;set_alloc(DB *db,
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
50 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a> and
51 <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a> methods to allocate or free
52 memory owned by the application.
53 </p>
54 <p>
55 There are a number of interfaces in Berkeley DB where memory is
56 allocated by the library and then given to the application. For
57 example, the <a class="link" href="dbt.html#dbt_DB_DBT_MALLOC">DB_DBT_MALLOC</a>
58 flag, when specified in the <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a>
59 object, will cause the <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a> methods to allocate and
60 reallocate memory which then becomes the responsibility of the calling
61 application. (See <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a>
62 for more information.) Other examples are the Berkeley DB interfaces
63 which return statistical information to the application:
64 <a class="xref" href="dbstat.html" title="DB-&gt;stat()">DB-&gt;stat()</a>,
65 <a class="xref" href="lockstat.html" title="DB_ENV-&gt;lock_stat()">DB_ENV-&gt;lock_stat()</a>,
66 <a class="xref" href="logarchive.html" title="DB_ENV-&gt;log_archive()">DB_ENV-&gt;log_archive()</a>,
67 <a class="xref" href="logstat.html" title="DB_ENV-&gt;log_stat()">DB_ENV-&gt;log_stat()</a>,
68 <a class="xref" href="mempstat.html" title="DB_ENV-&gt;memp_stat()">DB_ENV-&gt;memp_stat()</a>,
69 and <a class="xref" href="txnstat.html" title="DB_ENV-&gt;txn_stat()">DB_ENV-&gt;txn_stat()</a>. There is
70 one method in Berkeley DB where memory is allocated by the application
71 and then given to the library: <a class="xref" href="dbassociate.html" title="DB-&gt;associate()">DB-&gt;associate()</a>.
72 </p>
73 <p>
74 On systems in which there may be multiple library versions of the
75 standard allocation routines (notably Windows NT), transferring memory
76 between the library and the application will fail because the Berkeley
77 DB library allocates memory from a different heap than the application
78 uses to free it. To avoid this problem, the
79 <a class="xref" href="envset_alloc.html" title="DB_ENV-&gt;set_alloc()">DB_ENV-&gt;set_alloc()</a> and
80 <code class="methodname">DB-&gt;set_alloc()</code> methods can be used to pass Berkeley DB references to
81 the application's allocation routines.
82 </p>
83 <p>
84 It is not an error to specify only one or two of the possible
85 allocation function parameters to these interfaces; however, in that
86 case the specified interfaces must be compatible with the standard
87 library interfaces, as they will be used together. The functions
88 specified must match the calling conventions of the ANSI C X3.159-1989
89 (ANSI C) library routines of the same name.
90 </p>
91 <p>
92 Because databases opened within Berkeley DB environments use the
93 allocation interfaces specified to the environment, it is an error to
94 attempt to set those interfaces in a database created within an
95 environment.
96 </p>
97 <p>
98 The <code class="methodname">DB-&gt;set_alloc()</code> method may not be called after the
99 <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a> method is called.
100 </p>
101 <p>
102 The <code class="methodname">DB-&gt;set_alloc()</code> <span>
103 <span>
104 method returns a non-zero error value on failure and 0 on success.
105 </span>
106
107 </span>
108 </p>
109 <div class="sect2" lang="en" xml:lang="en">
110 <div class="titlepage">
111 <div>
112 <div>
113 <h3 class="title"><a id="idp50038528"></a>Errors</h3>
114 </div>
115 </div>
116 </div>
117 <p>
118 The <code class="methodname">DB-&gt;set_alloc()</code> <span>
119 <span>
120 method may fail and return one of the following non-zero errors:
121 </span>
122
123 </span>
124 </p>
125 <div class="sect3" lang="en" xml:lang="en">
126 <div class="titlepage">
127 <div>
128 <div>
129 <h4 class="title"><a id="idp50039384"></a>EINVAL</h4>
130 </div>
131 </div>
132 </div>
133 <p>
134 If called in a database environment, or called after
135 <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a> was called; or if an
136 invalid flag value or parameter was specified.
137 </p>
138 </div>
139 </div>
140 <div class="sect2" lang="en" xml:lang="en">
141 <div class="titlepage">
142 <div>
143 <div>
144 <h3 class="title"><a id="idp50036752"></a>Class</h3>
145 </div>
146 </div>
147 </div>
148 <p>
149 <a class="link" href="db.html" title="Chapter 2.  The DB Handle">DB</a>
150 </p>
151 </div>
152 <div class="sect2" lang="en" xml:lang="en">
153 <div class="titlepage">
154 <div>
155 <div>
156 <h3 class="title"><a id="idp50056000"></a>See Also</h3>
157 </div>
158 </div>
159 </div>
160 <p>
161 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
162 </p>
163 </div>
164 </div>
165 <div class="navfooter">
166 <hr />
167 <table width="100%" summary="Navigation footer">
168 <tr>
169 <td width="40%" align="left"><a accesskey="p" href="dbrename.html">Prev</a> </td>
170 <td width="20%" align="center">
171 <a accesskey="u" href="db.html">Up</a>
172 </td>
173 <td width="40%" align="right"> <a accesskey="n" href="dbset_append_recno.html">Next</a></td>
174 </tr>
175 <tr>
176 <td width="40%" align="left" valign="top">DB-&gt;rename() </td>
177 <td width="20%" align="center">
178 <a accesskey="h" href="index.html">Home</a>
179 </td>
180 <td width="40%" align="right" valign="top"> DB-&gt;set_append_recno()</td>
181 </tr>
182 </table>
183 </div>
184 </body>
185 </html>