Import BSDDB 4.7.25 (as of svn r89086)
This commit is contained in:
102
docs/api_cxx/env_set_alloc.html
Normal file
102
docs/api_cxx/env_set_alloc.html
Normal file
@@ -0,0 +1,102 @@
|
||||
<!--$Id: env_set_alloc.html 63573 2008-05-23 21:43:21Z trent.nelson $-->
|
||||
<!--Copyright (c) 1997,2008 Oracle. All rights reserved.-->
|
||||
<!--See the file LICENSE for redistribution information.-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Berkeley DB: DbEnv::set_alloc</title>
|
||||
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
|
||||
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
|
||||
</head>
|
||||
<body bgcolor=white>
|
||||
<table width="100%"><tr valign=top>
|
||||
<td>
|
||||
<b>DbEnv::set_alloc</b>
|
||||
</td>
|
||||
<td align=right>
|
||||
<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a>
|
||||
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
|
||||
</tr></table>
|
||||
<hr size=1 noshade>
|
||||
<tt>
|
||||
<b><pre>
|
||||
#include <db_cxx.h>
|
||||
<p>
|
||||
extern "C" {
|
||||
typedef void *(*db_malloc_fcn_type)(size_t);
|
||||
typedef void *(*db_realloc_fcn_type)(void *, size_t);
|
||||
typedef void *(*db_free_fcn_type)(void *);
|
||||
};
|
||||
<p>
|
||||
int
|
||||
DbEnv::set_alloc(db_malloc_fcn_type app_malloc,
|
||||
db_realloc_fcn_type app_realloc,
|
||||
db_free_fcn_type app_free);
|
||||
</pre></b>
|
||||
<hr size=1 noshade>
|
||||
<b>Description: DbEnv::set_alloc</b>
|
||||
<p>Set the allocation functions used by the <a href="../api_cxx/env_class.html">DbEnv</a> and <a href="../api_cxx/db_class.html">Db</a>
|
||||
methods to allocate or free memory owned by the application.</p>
|
||||
<p>There are a number of interfaces in Berkeley DB where memory is allocated by
|
||||
the library and then given to the application. For example, the
|
||||
<a href="../api_cxx/dbt_class.html#DB_DBT_MALLOC">DB_DBT_MALLOC</a> flag, when specified in the <a href="../api_cxx/dbt_class.html">Dbt</a> object,
|
||||
will cause the <a href="../api_cxx/db_class.html">Db</a> methods to allocate and reallocate memory
|
||||
which then becomes the responsibility of the calling application. (See
|
||||
<a href="../api_cxx/dbt_class.html">Dbt</a> for more information.) Other examples are the Berkeley DB
|
||||
interfaces which return statistical information to the application:
|
||||
<a href="../api_cxx/db_stat.html">Db::stat</a>, <a href="../api_cxx/lock_stat.html">DbEnv::lock_stat</a>, <a href="../api_cxx/log_archive.html">DbEnv::log_archive</a>,
|
||||
<a href="../api_cxx/log_stat.html">DbEnv::log_stat</a>, <a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, and <a href="../api_cxx/txn_stat.html">DbEnv::txn_stat</a>. There is one
|
||||
method in Berkeley DB where memory is allocated by the application and then
|
||||
given to the library: <a href="../api_cxx/db_associate.html">Db::associate</a>.</p>
|
||||
<p>On systems in which there may be multiple library versions of the
|
||||
standard allocation routines (notably Windows NT), transferring memory
|
||||
between the library and the application will fail because the Berkeley DB
|
||||
library allocates memory from a different heap than the application uses
|
||||
to free it. To avoid this problem, the DbEnv::set_alloc and
|
||||
<a href="../api_cxx/db_set_alloc.html">Db::set_alloc</a> methods can be used to pass Berkeley DB references to the
|
||||
application's allocation routines.</p>
|
||||
<p>It is not an error to specify only one or two of the possible allocation
|
||||
function parameters to these interfaces; however, in that case the
|
||||
specified interfaces must be compatible with the standard library
|
||||
interfaces, as they will be used together. The functions specified must
|
||||
match the calling conventions of the ANSI C X3.159-1989 (ANSI C) library routines of
|
||||
the same name.</p>
|
||||
<p>The DbEnv::set_alloc method configures operations performed using the specified
|
||||
<a href="../api_cxx/env_class.html">DbEnv</a> handle, not all operations performed on the underlying
|
||||
database environment.</p>
|
||||
<p>The DbEnv::set_alloc method may not be called after the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is
|
||||
called.
|
||||
</p>
|
||||
<p>The DbEnv::set_alloc method
|
||||
either returns a non-zero error value
|
||||
or throws an exception that encapsulates a non-zero error value on
|
||||
failure, and returns 0 on success.
|
||||
</p>
|
||||
<b>Parameters</b> <br>
|
||||
<b>app_malloc</b><ul compact><li>The <b>app_malloc</b> parameter is the application-specified malloc
|
||||
function.</ul>
|
||||
<b>app_realloc</b><ul compact><li>The <b>app_realloc</b> parameter is the application-specified realloc
|
||||
function.</ul>
|
||||
<b>app_free</b><ul compact><li>The <b>app_free</b> parameter is the application-specified free function.</ul>
|
||||
<br>
|
||||
<br><b>Errors</b>
|
||||
<p>The DbEnv::set_alloc method
|
||||
may fail and throw
|
||||
<a href="../api_cxx/except_class.html">DbException</a>,
|
||||
encapsulating one of the following non-zero errors, or return one of
|
||||
the following non-zero errors:</p>
|
||||
<br>
|
||||
<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_cxx/env_open.html">DbEnv::open</a> was called; or if an
|
||||
invalid flag value or parameter was specified.</ul>
|
||||
<br>
|
||||
<hr size=1 noshade>
|
||||
<br><b>Class</b>
|
||||
<a href="../api_cxx/env_class.html">DbEnv</a>
|
||||
<br><b>See Also</b>
|
||||
<a href="../api_cxx/env_list.html">Database Environments and Related Methods</a>
|
||||
</tt>
|
||||
<table width="100%"><tr><td><br></td><td align=right>
|
||||
<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
|
||||
</td></tr></table>
|
||||
<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user