<!--$Id: db_set_alloc.so,v 10.3 2002/08/18 21:15:51 bostic Exp $-->
<!--$Id: env_set_alloc.so,v 1.24 2008/01/19 14:12:57 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle. All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: DB->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>DB->set_alloc</b>
</td>
<td align=right>
<a href="../../db4-devel-4.7.25/api_c/api_core.html"><img src="../../db4-devel-4.7.25/images/api.gif" alt="API"></a>
<a href="../../db4-devel-4.7.25/ref/toc.html"><img src="../../db4-devel-4.7.25/images/ref.gif" alt="Ref"></a></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>
#include <db.h>
<p>
int
DB->set_alloc(DB *db,
void *(*app_malloc)(size_t),
void *(*app_realloc)(void *, size_t),
void (*app_free)(void *));
</pre></b>
<hr size=1 noshade>
<b>Description: DB->set_alloc</b>
<p>Set the allocation functions used by the <a href="../../db4-devel-4.7.25/api_c/env_class.html">DB_ENV</a> and <a href="../../db4-devel-4.7.25/api_c/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="../../db4-devel-4.7.25/api_c/dbt_class.html#DB_DBT_MALLOC">DB_DBT_MALLOC</a> flag, when specified in the <a href="../../db4-devel-4.7.25/api_c/dbt_class.html">DBT</a> object,
will cause the <a href="../../db4-devel-4.7.25/api_c/db_class.html">DB</a> methods to allocate and reallocate memory
which then becomes the responsibility of the calling application. (See
<a href="../../db4-devel-4.7.25/api_c/dbt_class.html">DBT</a> for more information.) Other examples are the Berkeley DB
interfaces which return statistical information to the application:
<a href="../../db4-devel-4.7.25/api_c/db_stat.html">DB->stat</a>, <a href="../../db4-devel-4.7.25/api_c/lock_stat.html">DB_ENV->lock_stat</a>, <a href="../../db4-devel-4.7.25/api_c/log_archive.html">DB_ENV->log_archive</a>,
<a href="../../db4-devel-4.7.25/api_c/log_stat.html">DB_ENV->log_stat</a>, <a href="../../db4-devel-4.7.25/api_c/memp_stat.html">DB_ENV->memp_stat</a>, and <a href="../../db4-devel-4.7.25/api_c/txn_stat.html">DB_ENV->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="../../db4-devel-4.7.25/api_c/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 <a href="../../db4-devel-4.7.25/api_c/env_set_alloc.html">DB_ENV->set_alloc</a> and
DB->set_alloc 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>Because databases opened within Berkeley DB environments use the allocation
interfaces specified to the environment, it is an error to attempt to
set those interfaces in a database created within an environment.</p>
<p>The DB->set_alloc method may not be called after the <a href="../../db4-devel-4.7.25/api_c/db_open.html">DB->open</a> method is called.
</p>
<p>The DB->set_alloc method
returns a non-zero error value on failure
and 0 on success.
</p>
<br><b>Errors</b>
<p>The DB->set_alloc method
may fail and return one of the following non-zero errors:</p>
<br>
<b>EINVAL</b><ul compact><li>If called in a database environment, or called after <a href="../../db4-devel-4.7.25/api_c/db_open.html">DB->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="../../db4-devel-4.7.25/api_c/db_class.html">DB</a>
<br><b>See Also</b>
<a href="../../db4-devel-4.7.25/api_c/db_list.html">Databases and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../../db4-devel-4.7.25/api_c/api_core.html"><img src="../../db4-devel-4.7.25/images/api.gif" alt="API"></a><a href="../../db4-devel-4.7.25/ref/toc.html"><img src="../../db4-devel-4.7.25/images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez