• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/docs/api_reference/CXX/
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 class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Db::set_alloc()</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="dbrename.html">Prev</a> </td>
22          <th width="60%" align="center">Chapter 2. 
23                The Db Handle
24        </th>
25          <td width="20%" align="right"> <a accesskey="n" href="dbset_append_recno.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="dbset_alloc"></a>Db::set_alloc()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db_cxx.h&gt;
39
40int
41Db::set_alloc(db_malloc_fcn_type app_malloc,
42    db_realloc_fcn_type app_realloc,
43    db_free_fcn_type app_free);</pre>
44      <p>
45         Set the allocation functions used by the 
46         <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>  and 
47         <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>  methods to allocate or free
48         memory owned by the application.
49    </p>
50      <p>
51         There are a number of interfaces in Berkeley DB where memory is
52         allocated by the library and then given to the application.  For
53         example, the <a class="link" href="dbt.html#dbt_DB_DBT_MALLOC">DB_DBT_MALLOC</a> 
54         flag, when specified in the <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> 
55         object, will cause the <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>  methods to allocate and
56         reallocate memory which then becomes the responsibility of the calling
57         application.  (See <a class="link" href="dbt.html" title="Chapter 4.  The Dbt Handle">Dbt</a> 
58         for more information.)  Other examples are the Berkeley DB interfaces
59         which return statistical information to the application: 
60         <a class="xref" href="dbstat.html" title="Db::stat()">Db::stat()</a>, 
61         <a class="xref" href="lockstat.html" title="DbEnv::lock_stat()">DbEnv::lock_stat()</a>, 
62         <a class="xref" href="logarchive.html" title="DbEnv::log_archive()">DbEnv::log_archive()</a>, 
63         <a class="xref" href="logstat.html" title="DbEnv::log_stat()">DbEnv::log_stat()</a>, 
64         <a class="xref" href="mempstat.html" title="DbEnv::memp_stat()">DbEnv::memp_stat()</a>, 
65         and <a class="xref" href="txnstat.html" title="DbEnv::txn_stat()">DbEnv::txn_stat()</a>.  There is
66         one method in Berkeley DB where memory is allocated by the application
67         and then given to the library: <a class="xref" href="dbassociate.html" title="Db::associate()">Db::associate()</a>.
68    </p>
69      <p>
70         On systems in which there may be multiple library versions of the
71         standard allocation routines (notably Windows NT), transferring memory
72         between the library and the application will fail because the Berkeley
73         DB library allocates memory from a different heap than the application
74         uses to free it.  To avoid this problem, the 
75         <a class="xref" href="envset_alloc.html" title="DbEnv::set_alloc()">DbEnv::set_alloc()</a>  and
76         <code class="methodname">Db::set_alloc()</code> methods can be used to pass Berkeley DB references to
77         the application's allocation routines.
78    </p>
79      <p>
80         It is not an error to specify only one or two of the possible
81         allocation function parameters to these interfaces; however, in that
82         case the specified interfaces must be compatible with the standard
83         library interfaces, as they will be used together.  The functions
84         specified must match the calling conventions of the ANSI C X3.159-1989
85         (ANSI C) library routines of the same name.
86    </p>
87      <p>
88         Because databases opened within Berkeley DB environments use the
89         allocation interfaces specified to the environment, it is an error to
90         attempt to set those interfaces in a database created within an
91         environment.
92    </p>
93      <p>
94             The <code class="methodname">Db::set_alloc()</code> method may not be called after the 
95             <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a>  method is called.
96    </p>
97      <p>
98         The <code class="methodname">Db::set_alloc()</code> <span>
99            
100            <span>
101                method either returns a non-zero error value or throws an
102                exception that encapsulates a non-zero error value on
103                failure, and returns 0 on success.
104            </span>
105        </span>
106    </p>
107      <div class="sect2" lang="en" xml:lang="en">
108        <div class="titlepage">
109          <div>
110            <div>
111              <h3 class="title"><a id="id1642846"></a>Errors</h3>
112            </div>
113          </div>
114        </div>
115        <p>
116            The <code class="methodname">Db::set_alloc()</code> <span>
117            
118            <span>
119                method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 
120                exception, encapsulating one of the following non-zero errors, or return one
121                of the following non-zero errors:
122            </span>
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="id1642993"></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::open()">Db::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="id1643002"></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="id1642935"></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::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::set_append_recno()</td>
181        </tr>
182      </table>
183    </div>
184  </body>
185</html>
186