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_env_create</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="env.html" title="Chapter��5.�� The DB_ENV Handle" /> 11 <link rel="prev" href="envclose.html" title="DB_ENV->close()" /> 12 <link rel="next" href="envdbremove.html" title="DB_ENV->dbremove()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">db_env_create</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envclose.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��5.�� 23 The DB_ENV Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="envdbremove.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="envcreate"></a>db_env_create</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41db_env_create(DB_ENV **dbenvp, u_int32_t flags); </pre> 42 <p> 43 The <code class="function">db_env_create()</code> function creates a <code class="classname">DB_ENV</code> 44 structure that is the handle for a Berkeley DB environment. This function allocates memory for the structure, 45 returning a pointer to the structure in the memory to which 46 <span class="bold"><strong>dbenvp</strong></span> refers. To release the allocated memory and discard the 47 handle, call the 48 <a class="xref" href="envclose.html" title="DB_ENV->close()">DB_ENV->close()</a> or 49 <a class="xref" href="envremove.html" title="DB_ENV->remove()">DB_ENV->remove()</a> methods. 50 </p> 51 <p> 52 <code class="classname">DB_ENV</code> handles are free-threaded if the 53 <a class="link" href="envopen.html#envopen_DB_THREAD">DB_THREAD</a> flag is specified to the 54 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method when the environment is opened. 55 The <code class="classname">DB_ENV</code> handle should not be closed while any other handle 56 remains open that is using it as a reference (for example, 57 <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> or <a class="link" href="txn.html" title="Chapter��12.�� The DB_TXN Handle">DB_TXN</a>). 58 Once either the 59 <a class="xref" href="envclose.html" title="DB_ENV->close()">DB_ENV->close()</a> or 60 <a class="xref" href="envremove.html" title="DB_ENV->remove()">DB_ENV->remove()</a> 61 methods are called, the handle may not be accessed again, regardless of the method's return. 62 </p> 63 <p> 64 Before the handle may be used, you must open it using the 65 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 66 method. 67 </p> 68 <p> 69 The DB_ENV handle contains a special field, <code class="literal">app_private</code>, which is declared as type 70 <code class="literal">void *</code>. This field is 71 provided for the use of the application program. It is initialized to NULL and is not further used by 72 Berkeley DB in any way. 73 </p> 74 <p> 75 The <code class="function">db_env_create()</code> method returns a non-zero error value on failure and 0 on success. 76 </p> 77 <p> 78 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0. 79 </p> 80 <div class="itemizedlist"> 81 <ul type="disc"></ul> 82 </div> 83 <div class="sect2" lang="en" xml:lang="en"> 84 <div class="titlepage"> 85 <div> 86 <div> 87 <h3 class="title"><a id="id1660932"></a>Class</h3> 88 </div> 89 </div> 90 </div> 91 <p> 92 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> 93 </p> 94 </div> 95 <div class="sect2" lang="en" xml:lang="en"> 96 <div class="titlepage"> 97 <div> 98 <div> 99 <h3 class="title"><a id="id1660933"></a>See Also</h3> 100 </div> 101 </div> 102 </div> 103 <p> 104 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 105 </p> 106 </div> 107 </div> 108 <div class="navfooter"> 109 <hr /> 110 <table width="100%" summary="Navigation footer"> 111 <tr> 112 <td width="40%" align="left"><a accesskey="p" href="envclose.html">Prev</a>��</td> 113 <td width="20%" align="center"> 114 <a accesskey="u" href="env.html">Up</a> 115 </td> 116 <td width="40%" align="right">��<a accesskey="n" href="envdbremove.html">Next</a></td> 117 </tr> 118 <tr> 119 <td width="40%" align="left" valign="top">DB_ENV->close()��</td> 120 <td width="20%" align="center"> 121 <a accesskey="h" href="index.html">Home</a> 122 </td> 123 <td width="40%" align="right" valign="top">��DB_ENV->dbremove()</td> 124 </tr> 125 </table> 126 </div> 127 </body> 128</html> 129